Removed no-comments option from init command

This commit is contained in:
mattstypa 2019-03-15 09:15:16 -05:00
parent 71b11a667a
commit 6d65dfb058
6 changed files with 2 additions and 151 deletions

View file

@ -13,15 +13,10 @@ export const options = [
usage: '--full',
description: 'Generate complete configuration file.',
},
{
usage: '--no-comments',
description: 'Omit comments from the config file.',
},
]
export const optionMap = {
full: ['full'],
noComments: ['no-comments'],
}
/**
@ -36,15 +31,12 @@ export function run(cliParams, cliOptions) {
utils.header()
const full = cliOptions.full
const noComments = cliOptions.noComments
const file = cliParams[0] || constants.defaultConfigFile
utils.exists(file) && utils.die(chalk.bold.magenta(file), 'already exists.')
const stubFile = full ? constants.defaultConfigStubFile : constants.simpleConfigStubFile
let stub = utils.readFile(stubFile)
noComments && (stub = utils.stripBlockComments(stub))
const stub = utils.readFile(stubFile)
utils.writeFile(file, stub)

View file

@ -1,7 +1,6 @@
import chalk from 'chalk'
import { ensureFileSync, existsSync, outputFileSync, readFileSync } from 'fs-extra'
import { findKey, mapValues, trimStart } from 'lodash'
import stripComments from 'strip-comments'
import * as emoji from './emoji'
import packageJson from '../../package.json'
@ -122,17 +121,3 @@ export function writeFile(path, content) {
return outputFileSync(path, content)
}
/**
* Strips block comments from input string. Consolidates multiple line breaks.
*
* @param {string} input
* @return {string}
*/
export function stripBlockComments(input) {
return stripComments
.block(input, { keepProtected: true })
.replace(/\n\s*\n\s*\n/g, '\n\n') // Strip unnecessary line breaks
.trim()
.concat('\n')
}