-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
36 lines (30 loc) · 991 Bytes
/
index.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
var mkdirp = require('mkdirp');
var path = require('path');
var ncp = require('ncp');
// Don't run this if the original folder where we run `yarn install` is the same as the current folder
var topLvlPackage = path.relative("" + process.env.DIR, __dirname) == ""
if (topLvlPackage) {
return;
}
var assetDir = 'Assets';
var project = require('./p.json');
for (var i = 0, l = project.assets.length; i < l; i++) {
var file = project.assets[i];
var src = path.join(__dirname, assetDir, file);
var dir = path.join(__dirname, '..', '..', assetDir, file);
var parentDir = path.dirname(dir);
// Create folder if missing
mkdirp(parentDir, function(_src, _dir, err) {
if (err) {
console.error(err)
process.exit(1);
}
// Copy files
ncp(_src, _dir, function(err) {
if (err) {
console.error(err);
process.exit(1);
}
});
}.bind(this, src, dir));
}