deploy: remove aq.join/add output dir to print/describe/run

This commit is contained in:
Christopher Monsanto 2020-08-13 01:35:14 -04:00
parent 193d4e35b9
commit baf1564e4c
3 changed files with 11 additions and 23 deletions

View File

@ -33,13 +33,11 @@ program
const dst = script.runOnFile(scr, src);
aq.copy(src, dst);
}
aq.join(outputDir);
if (act) {
aq.run('copy');
aq.run(outputDir, 'copy');
} else {
aq.print();
aq.print(outputDir);
}
});
@ -54,13 +52,11 @@ program
const scr = new script.Script(file, 'file');
script.run(scr, nodePath.dirname(file), aq);
}
aq.join(outputDir);
if (act) {
aq.run('link');
aq.run(outputDir, 'link');
} else {
aq.print();
aq.print(outputDir);
}
});

View File

@ -21,7 +21,7 @@ test('run identity', () => {
const aq = new script.ActionQueue();
const scr = new script.Script(` list(".").forEach(p => copy(p, p))`, 'expr');
script.run(scr, "testsrc", aq);
expect(aq.describe()).toEqual(expect.arrayContaining([
expect(aq.describe(".")).toEqual(expect.arrayContaining([
{src: 'testsrc/32.png', dst: "32.png"},
{src: 'testsrc/192-g-vsmogon.png', dst: "192-g-vsmogon.png"},
]));

View File

@ -25,30 +25,22 @@ export class ActionQueue {
this.map.set(dst, src);
}
describe() : {src : string, dst : string}[] {
describe(dir : string) : {src : string, dst : string}[] {
const result = [];
for (const [dst, src] of this.map) {
result.push({src,dst});
result.push({src,dst: nodePath.join(dir, dst)});
}
return result;
}
join(dir : string) {
const newMap = new Map;
for (const [dst, src] of this.map) {
newMap.set(nodePath.join(dir, dst), src);
}
this.map = newMap;
}
print() {
for (const {src, dst} of this.describe()) {
print(dir : string) {
for (const {src, dst} of this.describe(dir)) {
console.log(`${src} ==> ${dst}`);
}
}
run(mode : 'link' | 'copy') {
for (const {src, dst} of this.describe()) {
run(dir : string, mode : 'link' | 'copy') {
for (const {src, dst} of this.describe(dir)) {
fs.mkdirSync(nodePath.dirname(dst), {recursive: true});
if (mode === 'link') {
fs.linkSync(src, dst);