Skip to content

Commit

Permalink
feat(replace): now replaces and 'model_name' within file
Browse files Browse the repository at this point in the history
  • Loading branch information
robophil committed Oct 13, 2017
1 parent e534eef commit 48d1bc3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bin/cmd/types/model.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs-extra')
const path = require('path')
const replace = require('replace-in-file')
const cwd = process.cwd()

const dest = `${cwd}/src/models/`
Expand All @@ -13,9 +14,19 @@ module.exports = (names, options) => {
})
return copyAction
}).then(copyAction => Promise.all(copyAction).then(() => {

}).catch(err => console.dir(err))
).catch(err => {
const replaceAction = []
names.forEach(name => {
replaceAction.push(replace({
files: `${dest}${name}.js`,
from: /model_name/g,
to: name
}))
})
return replaceAction
}).catch(err => new Error(err))
.then(replaceAction => Promise.all(replaceAction).then(() => {
})).catch(err => new Error(err)))
.catch(err => {
if (err instanceof Error) throw err
else throw new Error(err)
})
Expand Down

0 comments on commit 48d1bc3

Please sign in to comment.