deploy: allow link to copy()

This commit is contained in:
Christopher Monsanto 2020-07-25 13:35:23 -04:00
parent 2a85d665bd
commit ca17fcd6e1
2 changed files with 7 additions and 3 deletions

View File

@ -2,10 +2,14 @@
import fs from 'fs';
import pathlib from 'path';
export function link(pairs : {src : string, dst : string}[], dstDir : string) {
export function link(pairs : {src : string, dst : string}[], dstDir : string, mode : 'link' | 'copy') {
for (let {src, dst} of pairs) {
dst = pathlib.join(dstDir, dst);
fs.mkdirSync(pathlib.dirname(dst), {recursive: true});
fs.linkSync(src, dst);
if (mode === 'link') {
fs.linkSync(src, dst);
} else {
fs.copyFileSync(src, dst);
}
}
}

View File

@ -10,7 +10,7 @@ program
.action((tag : string, outputDir : string, opts) => {
const dir = opts.dir || '.';
const results = run(find(dir, tag));
link(results, outputDir);
link(results, outputDir, 'link');
});
program