Skip to content

Commit 10b3bf9

Browse files
committed
make lint option work
1 parent 255701b commit 10b3bf9

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

args.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function parseArgs (args) {
1212
'populate--': true
1313
},
1414
number: ['port', 'inspect-port', 'body-limit', 'plugin-timeout'],
15-
string: ['log-level', 'address', 'socket', 'prefix', 'ignore-watch', 'logging-module', 'debug-host', 'lang', 'require'],
15+
string: ['log-level', 'address', 'socket', 'prefix', 'ignore-watch', 'logging-module', 'debug-host', 'lang', 'require', 'standardlint'],
1616
boolean: ['pretty-logs', 'options', 'watch', 'verbose-watch', 'debug'],
1717
envPrefix: 'FASTIFY_',
1818
alias: {
@@ -40,7 +40,8 @@ module.exports = function parseArgs (args) {
4040
debugPort: 9320,
4141
options: false,
4242
'plugin-timeout': 10 * 1000, // everything should load in 10 seconds
43-
lang: 'js'
43+
lang: 'js',
44+
standardlint: false
4445
}
4546
})
4647

generate.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const javascriptTemplate = {
3838
log('debug', `run '${chalk.bold('npm start')}' to start the application`)
3939
log('debug', `run '${chalk.bold('npm run dev')}' to start the application with pino-colada pretty logging (not suitable for production)`)
4040
log('debug', `run '${chalk.bold('npm test')}' to execute the unit tests`)
41+
42+
if (Object.keys(pkg.scripts).includes('lint')) {
43+
log('debug', `run '${chalk.bold('npm lint')}' to run linter and fix code style issues`)
44+
}
4145
}
4246
}
4347

@@ -149,7 +153,25 @@ function cli (args) {
149153
process.exit(1)
150154
}
151155

152-
const template = opts.lang === 'ts' || opts.lang === 'typescript' ? typescriptTemplate : javascriptTemplate
156+
let template
157+
if (opts.lang === 'ts' || opts.lang === 'typescript') {
158+
template = typescriptTemplate
159+
} else {
160+
template = { ...javascriptTemplate }
161+
162+
if (opts.standardlint) {
163+
template.scripts = {
164+
...template.scripts,
165+
pretest: 'standard',
166+
lint: 'standard --fix'
167+
}
168+
169+
template.devDependencies = {
170+
...template.devDependencies,
171+
standard: cliPkg.devDependencies.standard
172+
}
173+
}
174+
}
153175

154176
generate(dir, template).catch(function (err) {
155177
if (err) {

0 commit comments

Comments
 (0)