mirror of
https://github.com/smogon/sprites.git
synced 2026-04-24 14:57:28 -05:00
deploy: remove aq.join/add output dir to print/describe/run
This commit is contained in:
parent
193d4e35b9
commit
baf1564e4c
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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"},
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user