-
Notifications
You must be signed in to change notification settings - Fork 23
/
rm.js
47 lines (44 loc) · 1.04 KB
/
rm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
const Funnel = require('broccoli-funnel');
const debug = require('debug')('broccoli-stew:rm');
/**
* remove files from a tree.
*
* @example
* const rm = require('broccoli-stew').rm;
* const dist = 'lib';
*
* given:
* foo/bar/baz.js
* foo/bar/bar.js
* foo/bar/package.json
* foo/other/package.json
*
* tree = 'foo';
*
* dist = rm(tree, 'foo/bar/baz.js') => [
* foo/bar/bar.js
* foo/bar/package.json
* foo/other/package.json
* ];
*
* dist = rm(tree, 'foo/bar/*.js') => [
* foo/bar/baz.js
* foo/bar/bar.js
* ];
*
* dist = rm(tree, 'foo/bar/*.js', 'foo/bar/baz.js') => [
* foo/bar/bar.js
* ];
*
* module.exports = dist;
*
* @param {String|Object} tree The input tree
* @param {String} [remove] Pattern to match files to remove
* @return {Tree} Tree containing the removed files.
*/
module.exports = function rm(tree/*, ...exclude */) {
let exclude = Array.prototype.slice.call(arguments, 1, arguments.length);
debug('%s rm: %s', exclude);
return new Funnel(tree, { exclude });
};