clean method
void
clean()
Removes any of the dart build artifacts so you have a clean directory. We do this recursively so all subdirectories will also be purged.
Deletes: pubspec.lock ./packages .dart_tools
Any exes for scripts in the directory.
Implementation
void clean() {
_lock.withLock(
() {
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...',
);
}