just-scripts
Version:
Just Stack Scripts
37 lines • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanTask = exports.defaultCleanPaths = void 0;
const fse = require("fs-extra");
const path = require("path");
const just_task_1 = require("just-task");
const parallelLimit = require("run-parallel-limit");
function defaultCleanPaths() {
return ['lib', 'temp', 'dist', 'coverage'];
}
exports.defaultCleanPaths = defaultCleanPaths;
function cleanTask(pathsOrOptions = {}, limit) {
let paths;
if (Array.isArray(pathsOrOptions)) {
paths = pathsOrOptions;
}
else {
paths = pathsOrOptions.paths || defaultCleanPaths();
limit = limit || pathsOrOptions.limit;
}
limit = limit || 5;
return function clean(done) {
just_task_1.logger.info(`Removing [${paths.map(p => path.relative(process.cwd(), p)).join(', ')}]`);
const cleanTasks = paths
.map(cleanPath => function (cb) {
fse.remove(cleanPath, cb);
})
.concat((cb) => {
just_task_1.clearCache();
cb(null);
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
parallelLimit(cleanTasks, limit, done);
};
}
exports.cleanTask = cleanTask;
//# sourceMappingURL=cleanTask.js.map