-
Notifications
You must be signed in to change notification settings - Fork 4
/
deployapi.js
34 lines (31 loc) · 940 Bytes
/
deployapi.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
#!/usr/bin/env node
const path = require('path');
const fs = require('fs-extra');
async function main(folder) {
let modulefolder = __dirname;
let sampleFolder = path.join(modulefolder, 'sampleAPI');
// create folder, error out if already exists
try {
await fs.mkdir(folder);
} catch (e) {
console.error(e.message);
console.error('Unable to create directory ' + folder + '. Make sure it does not already exist.');
process.exit(1);
}
// copy sampleAPI over
try {
await fs.copy(sampleFolder, folder);
} catch (e) {
console.error(e);
console.error('Unable to copy sampleAPI into newly created directory.');
process.exit(1);
}
// display done, npm install to
console.log('create-mithril-app-api done.');
console.log('== to start ==');
console.log('cd ' + folder);
console.log('npm install');
console.log('npm run dev');
}
// console.log(process.argv);
main(process.argv[2]);