Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ npm i -g @stormid/scaffold-cli
## Usage
```
scaffold <project-name>
scaffolf <project-name> [--template=typescript]
```

## Options
Expand All @@ -18,5 +19,6 @@ scaffold <project-name>

--name The application name.
--cwd A directory to use instead of $PWD.
--install Installs dependencies. [boolean] [default: true]
--install Installs dependencies. [boolean] [default: true]
--template Templatename you want to scaffold ["default"|"typescript"] [default: "default"]
```
14 changes: 11 additions & 3 deletions lib/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ const gittar = require('gittar');
const fs = require('fs-extra');
const Table = require('cli-table');
const isValidName = require('validate-npm-package-name');
const REPO = 'stormid/scaffold';

const REPOS = {
default: 'stormid/scaffold',
typescript: 'damienasny/scaffold-ts'
};

module.exports = async function(dest, argv) {
if (!dest) {
Expand All @@ -32,7 +36,7 @@ module.exports = async function(dest, argv) {
return error(errors.map(capitalize).join('\n ~ '), 1);
}

let archive = await gittar.fetch(REPO).catch(err => {
let archive = await gittar.fetch(REPOS[argv.template]).catch(err => {
err = err || { message: 'An error occured while fetching the scaffold from Github' };
return error(
err.code === 404
Expand All @@ -50,7 +54,11 @@ module.exports = async function(dest, argv) {
},
});

await fs.mkdir(`${target}/src/assets`);
try {
await fs.mkdir(`${target}/src/assets`);
} catch (e) {
console.log(e)
}

let pkgData,
pkgFile = resolve(target, 'package.json');
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ sade('scaffold [dest]', true)
.option('--cwd', 'A directory to use instead of $PWD', '.')
.option('--install', 'Install dependencies', true)
.option('-v, --verbose', 'Verbose output')
.option('--template', 'The template name you want to scaffold', 'default')
.action(require('./commands'))
.parse(process.argv);