Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use npx to run Yeoman #5

Merged
merged 2 commits into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Installing via Homebrew will also install the latest version of Node.js on your
## Installation via NPM

```
$ npm install -g yo
$ npm install -g generator-swiftserver
$ npm install -g kitura-cli
```

Expand Down
17 changes: 5 additions & 12 deletions kitura-create.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
#!/usr/bin/env node

const chalk = require('chalk');
const program = require('commander');
const spawn = require('child_process').spawn;
const spawnSync = require('child_process').spawnSync;

program
.arguments('[modelname]')
.parse(process.argv);

// Run NPM to install the Yeoman generator
var npm = spawnSync('npm', ['install', '-g', 'generator-swiftserver'], { stdio: 'inherit' });
if (npm.error) {
console.error(chalk.red('Error: ') + 'NPM package installation failed');
process.exit(npm.status);
}

let options = ['swiftserver']
let options = ['-p', 'yo@1', '-p', 'generator-swiftserver', '--', 'yo'];

// If a parameter is passed, use this as a model name
if (program.args[0]) {
options = ['swiftserver:model', program.args[0]];
options.push('swiftserver:model', program.args[0]);
} else {
options.push('swiftserver');
}

// Run the generator
let child = spawn('yo', options, { stdio: 'inherit' });
let child = spawn('npx', options, { stdio: 'inherit' });
child.on('error', (err) => {
console.error(err);
});
Expand Down
11 changes: 1 addition & 10 deletions kitura-init.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
#!/usr/bin/env node

const chalk = require('chalk');
const program = require('commander');
const spawn = require('child_process').spawn;
const spawnSync = require('child_process').spawnSync;

program
.parse(process.argv);

// Run NPM to install the Yeoman generator
var npm = spawnSync('npm', ['install', '-g', 'generator-swiftserver'], { stdio: 'inherit' });
if (npm.error) {
console.error(chalk.red('Error: ') + 'NPM package installation failed');
process.exit(npm.status);
}

let child = spawn('yo', ['swiftserver', '--init'], { stdio: 'inherit' });
let child = spawn('npx', ['-p', 'yo@1', '-p', 'generator-swiftserver', '--', 'yo', 'swiftserver', '--init'], { stdio: 'inherit' });
child.on('error', (err) => {
console.error(err);
});
Expand Down
38 changes: 15 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.