|
|
|
@ -1,15 +1,18 @@
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const child_process = require('child_process');
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
const glob = require('tiny-glob/sync.js');
|
|
|
|
|
const shell = require("shelljs");
|
|
|
|
|
|
|
|
|
|
const bin = path.resolve(`svelte`);
|
|
|
|
|
const cli = path.resolve(__dirname, "../../cli/index.ts.js");
|
|
|
|
|
|
|
|
|
|
function normalize(str) {
|
|
|
|
|
return str
|
|
|
|
|
.replace(/^\s+$/gm, '')
|
|
|
|
|
.replace(/generated by Svelte v[.\d]+/, `generated by Svelte vx.y.z`)
|
|
|
|
|
.replace(
|
|
|
|
|
/\/\*(.*?)generated by Svelte v[.\d]+/,
|
|
|
|
|
(_, path) => `/*${path.replace(/\\/g, '/')}generated by Svelte vx.y.z`
|
|
|
|
|
)
|
|
|
|
|
.trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -31,14 +34,14 @@ describe('cli', () => {
|
|
|
|
|
|
|
|
|
|
const command = fs.readFileSync('command.sh', 'utf-8');
|
|
|
|
|
|
|
|
|
|
child_process.exec(`
|
|
|
|
|
alias svelte=${bin}
|
|
|
|
|
mkdir -p actual
|
|
|
|
|
rm -rf actual/*
|
|
|
|
|
${command}
|
|
|
|
|
`, (err, stdout, stderr) => {
|
|
|
|
|
if (err) {
|
|
|
|
|
done(err);
|
|
|
|
|
shell.mkdir("-p", "actual");
|
|
|
|
|
shell.rm("-rf", "actual/*");
|
|
|
|
|
const { commandErr } = shell.exec(
|
|
|
|
|
command.replace(/^svelte /, `node ${cli} `)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (commandErr) {
|
|
|
|
|
done(commandErr);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -76,4 +79,3 @@ describe('cli', () => {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|