-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathos-specific-copy.js
More file actions
30 lines (23 loc) · 796 Bytes
/
Copy pathos-specific-copy.js
File metadata and controls
30 lines (23 loc) · 796 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
const sys = require('util');
const os = require('os');
const exec = require('child_process').exec;
const PATHS = [
['src\\template\\logger.html', 'out\\template\\logger.html']
]
function constructCommand(cmd, transform) {
return PATHS.map(arr => arr.map(transform))
.map(([src, dest]) => `${cmd} ${src} ${dest}`)
.join(' && ');
}
function puts(error, stdout, stderr) {
console.log(stdout);
}
let command = '';
if (os.type() === 'Linux' || os.type() === 'Darwin')
command = constructCommand('cp', x => x.replace(/\\/g, '/'));
else if (os.type() === 'Windows_NT')
command = constructCommand('copy', x => x);
else
throw new Error("Unsupported OS found: " + os.type());
console.log(`Running command ${command}...`);
exec(command, puts);