forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyFile.js
More file actions
25 lines (21 loc) · 693 Bytes
/
copyFile.js
File metadata and controls
25 lines (21 loc) · 693 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
'use strict';
const logger = require('./log');
const events = require('./events');
let copy = require('recursive-copy'); // eslint-disable-line prefer-const
const copyFile = (p, dest, options) => {
return copy(p, dest, options)
.on(copy.events.ERROR, function (error, copyOperation) {
logger.error('Unable to copy ' + copyOperation.dest);
})
.on(copy.events.COPY_FILE_ERROR, (error) => {
logger.error(error);
})
.on(copy.events.COPY_FILE_COMPLETE, () => {
logger.debug(`Moved ${p} to ${dest}`);
options.emitter.emit(events.PATTERNLAB_PATTERN_ASSET_CHANGE, {
file: p,
dest: dest,
});
});
};
module.exports = copyFile;