diff --git a/tools/deploy/import.ts b/tools/deploy/import.ts deleted file mode 100644 index 63234ae7..00000000 --- a/tools/deploy/import.ts +++ /dev/null @@ -1,22 +0,0 @@ - -import fs from 'fs'; -import vm from 'vm'; -import * as pathlib from './path.js'; - -export function imp(files: string[], code : string) { - const script = new vm.Script(code); - - const results = []; - for (const file of files) { - const parsed = pathlib.parse(file); - const delta = script.runInNewContext({path: parsed, ...parsed}); - if (delta) { - const result = pathlib.path(parsed, delta); - const dest = pathlib.format(result); - results.push({src: file, dst: dest}); - } else { - throw new Error(`result of eval on ${file} falsy`); - } - } - return results; -} diff --git a/tools/deploy/index.ts b/tools/deploy/index.ts index 24a0def3..ce84417c 100644 --- a/tools/deploy/index.ts +++ b/tools/deploy/index.ts @@ -3,7 +3,8 @@ import program from 'commander'; import {run} from './lang.js'; import {find} from './find.js'; import {link} from './deploy.js'; -import {imp} from './import.js'; +import * as script from './script.js'; +import * as pathlib from './path.js'; import fs from 'fs'; function collect(value : string, previous : string[]) { @@ -27,8 +28,17 @@ program throw new Error(`one of -e or -m must be provided`); } - const result = imp(files, code); - link(result, outputDir, 'copy'); + const aq = new script.ActionQueue; + const scr = new script.Script(code); + + for (const file of files) { + const src = pathlib.path(file); + const dst = pathlib.path(src, scr.runOnFile(src)); + aq.copy(src, dst); + } + + // TODO: output + aq.run('copy'); }); program