Skip to content

Implement 'Waiting' Property on NamedLock.guard() #6

@tsavo-at-pieces

Description

@tsavo-at-pieces

With the old DCLI NamedLock Package it would be:

await _lock.withLock(
      () async {
        find(
          '.packages',
          types: [Find.file],
          workingDirectory: pathToProjectRoot,
        ).forEach(delete);

        /// we cant delete directories whilst recusively scanning them.
        final toBeDeleted = <String>[];
        find(
          '.dart_tool',
          types: [Find.directory],
          workingDirectory: pathToProjectRoot,
        ).forEach(toBeDeleted.add);

        _deleteDirs(toBeDeleted);

        find('pubspec.lock', workingDirectory: pathToProjectRoot)
            .forEach(delete);

        find('*.dart', workingDirectory: pathToProjectRoot)
            .forEach((scriptPath) {
          final script = DartScript.fromFile(scriptPath);
          if (exists(script.pathToExe)) {
            delete(script.pathToExe);
          }
        });
      },
      waiting: 'Waiting for clean to complete...',
    );

And now with this package it would be:

final ExecutionCall<bool, Exception> _execution = NamedLock.guard(
      name: name,
      execution: ExecutionCall<bool, Exception>(
        callable: () {
         //...
          return true;
        },
      waiting: 'Waiting for clean to complete...',
      ),
    );

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions