UNPKG

699 BJavaScriptView Raw
1'use strict';
2
3var path = require('path');
4var fs = require('fs');
5var runnel = require('runnel');
6
7var loadersDir = path.join(__dirname, '..', 'loaders');
8
9var cleanLoaders = module.exports = function (cb) {
10
11 // we'll only ever put files in there, so we don't need to filter and save a call to fs.stat
12 fs.readdir(loadersDir, function (err, files) {
13 if (err) return cb(err);
14
15 var tasks = files
16 .filter(function (file) { return file !== '.gitignore'; })
17 .map(function (file) {
18 return function rm (cb_) {
19 fs.unlink(path.join(loadersDir, file), cb_);
20 };
21 });
22
23 if (!tasks.length) return cb();
24
25 runnel(tasks.concat(cb));
26 });
27};