-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-dist-files.js
32 lines (31 loc) · 942 Bytes
/
copy-dist-files.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
var fs = require('fs-extra');
// resources[0] = source folder, resources[1] = destination folder.
var resources = ['src/assets/img', 'dist/assets/img'];
function paths( arr ) {
return new Promise(function(resolve, reject){
var lInd = arr.length-1;
arr.forEach(function(v, i, arr){
fs.ensureDir(v)
.then(function() {
if(i === lInd)resolve(arr);
})
.catch(function ( err ) {
reject(err);
});
});
});
}
paths(resources)
.then(function ( r ) {
fs.copy(r[0], r[1])
.then( function(r) {
console.log('Copied successed!');
})
.catch(function ( err ) {
console.error(err);
});
})
.catch(function ( err ) {
console.error(err);
});
// Copyright (c) 2017 Alex Tranchenko. All rights reserved.