-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·40 lines (30 loc) · 1.13 KB
/
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
38
39
40
#!/usr/bin/env node
const execa = require('execa');
const whoRanMe = require('who-ran-me');
const minimist = require('minimist');
const { join, dirname } = require('path');
const indexFile = require.resolve('ember-cli');
const emberPath = join(dirname(indexFile), '../../bin/ember');
const parsedArgs = minimist(process.argv.slice(2));
const args = ['addon'];
// yarn reports the bin script from who-ran-me
if (['yarn', 'create-ember-ghost-template', 'create-empress-blog-template'].includes(whoRanMe())) {
args.push('--yarn');
}
const templateName = parsedArgs._[0];
const pluginName = `empress-blog-${templateName}-template`;
args.push(pluginName);
for (let i = 2; i < process.argv.length; i += 1) {
if (process.argv[i] !== templateName) {
args.push(process.argv[i]);
}
}
(async () => {
try {
await execa(emberPath, args, { stdio: 'inherit' });
await execa(emberPath, ['install', 'empress-blog', 'empress-blog-starter-template'], { cwd: pluginName, stdio: 'inherit' });
} catch (err) {
// eslint-disable-next-line no-console
console.error(`Error running 'create-empress-blog-template': ${err.message}`, err);
}
})();