Comparing version 0.1.3 to 0.1.4
@@ -72,3 +72,2 @@ 'use strict'; | ||
else if (program.generate) { | ||
console.log(chalk.underline.cyan.bold('Experimental feature.')); | ||
} | ||
@@ -75,0 +74,0 @@ else if (program.reset) { |
@@ -8,2 +8,3 @@ var chalk = require('chalk'); | ||
var slugify = require('slugify'); | ||
var mkdirp = require('mkdirp'); | ||
var typeExtensions = { | ||
@@ -36,2 +37,4 @@ element: ['jade', 'styl', 'md'], | ||
_.each(names, function(name) { | ||
console.log(chalk.green.bold('Generate resource type: ') + chalk.white.underline(type)); | ||
console.log(chalk.green.bold('Resource name: ') + chalk.white.underline(name)); | ||
_.each(extensions, function(extension) { | ||
@@ -46,13 +49,8 @@ // template string + data for template | ||
// target path | ||
var filePath = path.join(config.sourceDir, config.sourcePaths.viewsDir, pluralize(type), name, name + '.' + extension); | ||
// ensure directories exists before saving template | ||
filePath.split('/').slice(0, -1).reduce(function(prev, curr, i) { | ||
if (fs.existsSync(prev) === false) { | ||
fs.mkdirSync(prev); | ||
} | ||
return prev + '/' + curr; | ||
}); | ||
var filePath = path.join(config.sourceDir, config.sourcePaths.viewsDir, pluralize(type), name); | ||
var fileName = name + '.' + extension; | ||
mkdirp.sync(filePath); | ||
// write file | ||
fs.writeFileSync(filePath, data, 'utf-8'); | ||
console.log(chalk.green.bold('Success: ' + chalk.underline.white(filePath))); | ||
fs.writeFileSync(path.join(filePath, fileName), data, 'utf-8'); | ||
console.log(chalk.green.bold('Success: ' + chalk.underline.white(fileName) + ' in ' + chalk.underline.white(filePath))); | ||
}); | ||
@@ -59,0 +57,0 @@ }); |
{ | ||
"name": "cml-cli", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Simple wrapper for build scripts to stabilize API and to scaffold views and common patterns of cml-frontend boilerplate. Not for standalone usage.", | ||
@@ -24,6 +24,7 @@ "bin": { | ||
"chalk": "^1.0.0", | ||
"commander": "~2.0.0", | ||
"commander": "^2.0.0", | ||
"fs-extra": "^0.18.3", | ||
"get-port": "^1.0.0", | ||
"lodash": "^3.9.3", | ||
"mkdirp": "^0.5.1", | ||
"pluralize": "^1.1.2", | ||
@@ -30,0 +31,0 @@ "slugify": "^0.1.1", |
14892
11
399
+ Addedmkdirp@^0.5.1
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
- Removedcommander@2.0.0(transitive)
Updatedcommander@^2.0.0