mirror of
https://github.com/smogon/sprites.git
synced 2026-07-05 19:07:08 -05:00
deploy: use actionqueue/script for copy cli
This commit is contained in:
parent
49c5f5a873
commit
e5812e2da0
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user