Skip to content

Commit

Permalink
Use "customize-write-files" to save the resulting files to disk.
Browse files Browse the repository at this point in the history
- This adds support for subdirectories in the template folder
  • Loading branch information
Nils Knappmeier committed Jan 21, 2016
1 parent 8ad63d2 commit 781f63e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 2 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var Q = require('q')
var qfs = require('q-io/fs')
var fs = require('fs')
var debug = require('debug')('thought:run')
var write = require('customize-write-files')

module.exports = thought

Expand All @@ -27,18 +28,7 @@ function thought (options) {
// Load `customize`-spec
.load(require('./customize.js')(options.cwd || '.'))
.run()
.then(function (result) {
debug('customize-result', result)
return Q.all(Object.keys(result.handlebars).map(function (filename) {
// qfs.write has issues in node 4.1.0, so we create a simple wrapper using
// Q.defer() and fs.writeFile()
var defer = Q.defer();
fs.writeFile(filename, result.handlebars[filename], defer.makeNodeResolver());
return defer.promise.then(function () {
return filename
})
}))
})
.then(write(options.cwd || '.'))
.then(function (filenames) {
if (options['addToGit']) {
// Add computed files to the git index.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"commander": "^2.8.1",
"customize": "<1.0.0",
"customize-engine-handlebars": "<1.0.0",
"customize-write-files": "^0.1.2",
"debug": "^2.2.0",
"find-package": "^1.0.0",
"get-promise": "^1.3.1",
Expand Down

0 comments on commit 781f63e

Please sign in to comment.