-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (28 loc) · 868 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
'use strict';
process.env.SVELTE_SCRIPTS = 'app';
process.on('unhandledRejection', err => {
throw err;
});
const { spawnSync } = require('child_process');
const args = process.argv.slice(2);
const scripts = ['start', 'build', 'test'];
if (args.length === 0) {
console.log('\x1b[31mEmpty script.');
process.exit(1);
}
const script = args[0];
console.log(`\x1b[36m\nSvelte Scripts (${script})`, '\x1b[0m');
console.log(`🚀 Version: ${require('./package.json').version}\n`);
if (scripts.includes(script)) {
const result = spawnSync(
'node',
[`${__dirname}/scripts/${script}.js`, ...process.argv.slice(3)],
{ stdio: 'inherit' }
);
process.exit(result.status);
} else {
console.log(`\x1b[31mUnknown script ${script}.\x1b[0m`);
console.log('See: http://github.com/andrelmlins/svelte-scripts');
process.exit(1);
}