A new command line tool and developer framework for scaffolding out GitHub projects. Generate offers the robustness and configurability of Yeoman, the expressiveness and simplicity of Slush, and more powerful flow control and composability than either.
generate
$ gen —macro foo @my-org/generate-foo
app.cache.answers
.data-store
, it seems like if I set {save: true}
as an option to my questions, and the value is previously populated in the data-store, it will skip the question entirely, rather than setting the stored value as a default option
{save: true}
will save the answers to the data-store
like you said… this should be one specified for the current project that you’re working in. To force the question to be asked event when there is a value already set, use {force: true}
for that question
import path from 'path'
import isValid from 'is-valid-app'
import lodashEngine from 'engine-lodash'
import defaults from 'generate-defaults'
export default function(app) {
if (!isValid(app, 'generate-slo-mo')) return
app.use(defaults)
app.engine('*', lodashEngine)
app.questions.clearQuestions();
app.questions.clearAnswers();
app.task('default', () => {
app.questions.set('¯\_(ツ)_/¯.why', 'why does\'nt this work')
const dest = 'dist'
const src = path.join('src', 'index.html')
app.ask('¯\_(ツ)_/¯', { save: true }, function(err, answers) {
app.src(src, {cwd: __dirname})
.pipe(app.renderFile('*'))
.pipe(app.conflicts(app.cwd))
.pipe(app.dest(dest))
.on('end', err => {
console.log(app.cache.answers) // {}
});
})
})
}
app.cache.answers
is an empty object?
answers
passed in the callback is defined { '¯_(ツ)_/¯': { why: 'dunno' } }
base-questions
stores the answers on app.cache.answers
after the question is asked. I copied your example and it works for me. I changed the imports
to var foo = require(‘…’)
and changed export default
to module.exports =
since I’m not sure how you’re doing the transpiling step.
generate
are you using?
base-questions
or that something is happening during the transpiling… also, you should be passing a callback to the default task and calling it after the console.log
to indicate that the task has finished.
./packages
├── generator-slo-mo
│ ├── dist
│ │ └── index.html
│ ├── generator.js
│ ├── package.json
│ └── src
│ ├── generator.js
│ └── index.html
└── slo-mo
├── bin
│ └── cli.js
├── dist
│ ├── github.js
│ ├── slack.js
│ ├── slo-mo.js
│ ├── speedcurve.js
│ └── task.js
├── package.json
├── src
│ ├── github.js
│ ├── slack.js
│ ├── slo-mo.js
│ ├── speedcurve.js
│ └── task.js
└── test
└── sample-spec.js
generate
in an npm script in package.json
answers
appended on the cache
answers
would be added to app.cache.answers
after the ask
"version": "0.9.8"
[14:13:48] ✔ running tasks: [ 'default:default' ]