forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinknodemodules.js
More file actions
32 lines (30 loc) · 935 Bytes
/
linknodemodules.js
File metadata and controls
32 lines (30 loc) · 935 Bytes
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
var fs = require('fs');
var path = require('path');
module.exports = function(gulp, plugins, config) {
return function() {
var nodeModulesDir = path.join(config.dir, 'node_modules');
if (!fs.existsSync(nodeModulesDir)) {
fs.mkdirSync(nodeModulesDir);
}
getSubdirs(config.dir).forEach(function(relativeFolder) {
if (relativeFolder === 'node_modules') {
return;
}
var sourceDir = path.join('..', relativeFolder);
var linkDir = path.join(nodeModulesDir, relativeFolder);
if (!fs.existsSync(linkDir)) {
console.log('creating link', linkDir, sourceDir);
fs.symlinkSync(sourceDir, linkDir, 'dir');
}
});
};
};
function getSubdirs(rootDir) {
return fs.readdirSync(rootDir).filter(function(file) {
if (file[0] === '.') {
return false;
}
var dirPath = path.join(rootDir, file);
return fs.statSync(dirPath).isDirectory();
});
}