Skip to content

Commit 6d65dfb

Browse files
committed
Removed no-comments option from init command
1 parent 71b11a6 commit 6d65dfb

File tree

6 files changed

+2
-151
lines changed

6 files changed

+2
-151
lines changed

__tests__/cli.utils.test.js

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import path from 'path'
2-
31
import * as utils from '../src/cli/utils'
42

53
describe('cli utils', () => {
6-
const fixture = utils.readFile(path.resolve(__dirname, 'fixtures/cli-utils.js'))
7-
84
describe('parseCliParams', () => {
95
it('parses CLI parameters', () => {
106
const result = utils.parseCliParams(['a', 'b', '-c', 'd'])
@@ -60,53 +56,4 @@ describe('cli utils', () => {
6056
expect(result).toEqual({ test: ['c', 'd', 'h'] })
6157
})
6258
})
63-
64-
describe('stripBlockComments', () => {
65-
it('does not strip code', () => {
66-
const result = utils.stripBlockComments(fixture)
67-
68-
expect(result).toEqual(expect.stringContaining('__code_no_comment__'))
69-
expect(result).toEqual(expect.stringContaining('__code_comment_line__'))
70-
expect(result).toEqual(expect.stringContaining('__code_comment_block__'))
71-
expect(result).toEqual(expect.stringContaining('__code_comment_line_important__'))
72-
expect(result).toEqual(expect.stringContaining('__code_comment_block_important__'))
73-
})
74-
75-
it('strips block comments', () => {
76-
const result = utils.stripBlockComments(fixture)
77-
78-
expect(result).not.toEqual(expect.stringContaining('__comment_block__'))
79-
expect(result).not.toEqual(expect.stringContaining('__comment_block_multiline__'))
80-
expect(result).not.toEqual(expect.stringContaining('__comment_block_code__'))
81-
})
82-
83-
it('strips docblock comments', () => {
84-
const result = utils.stripBlockComments(fixture)
85-
86-
expect(result).not.toEqual(expect.stringContaining('__comment_docblock__'))
87-
})
88-
89-
it('does not strip line comments', () => {
90-
const result = utils.stripBlockComments(fixture)
91-
92-
expect(result).toEqual(expect.stringContaining('__comment_line__'))
93-
expect(result).toEqual(expect.stringContaining('__comment_line_important__'))
94-
expect(result).toEqual(expect.stringContaining('__comment_line_code__'))
95-
expect(result).toEqual(expect.stringContaining('__comment_line_important_code__'))
96-
})
97-
98-
it('does not strip important block comments', () => {
99-
const result = utils.stripBlockComments(fixture)
100-
101-
expect(result).toEqual(expect.stringContaining('__comment_block_important__'))
102-
expect(result).toEqual(expect.stringContaining('__comment_block_multiline_important__'))
103-
expect(result).toEqual(expect.stringContaining('__comment_block_important_code__'))
104-
})
105-
106-
it('does not strip important docblock comments', () => {
107-
const result = utils.stripBlockComments(fixture)
108-
109-
expect(result).toEqual(expect.stringContaining('__comment_docblock_important__'))
110-
})
111-
})
11259
})

__tests__/fixtures/cli-utils.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
"postcss-js": "^2.0.0",
5353
"postcss-nested": "^4.1.1",
5454
"postcss-selector-parser": "^6.0.0",
55-
"pretty-hrtime": "^1.0.3",
56-
"strip-comments": "^1.0.2"
55+
"pretty-hrtime": "^1.0.3"
5756
},
5857
"browserslist": [
5958
"> 1%"

src/cli/commands/init.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ export const options = [
1313
usage: '--full',
1414
description: 'Generate complete configuration file.',
1515
},
16-
{
17-
usage: '--no-comments',
18-
description: 'Omit comments from the config file.',
19-
},
2016
]
2117

2218
export const optionMap = {
2319
full: ['full'],
24-
noComments: ['no-comments'],
2520
}
2621

2722
/**
@@ -36,15 +31,12 @@ export function run(cliParams, cliOptions) {
3631
utils.header()
3732

3833
const full = cliOptions.full
39-
const noComments = cliOptions.noComments
4034
const file = cliParams[0] || constants.defaultConfigFile
4135

4236
utils.exists(file) && utils.die(chalk.bold.magenta(file), 'already exists.')
4337

4438
const stubFile = full ? constants.defaultConfigStubFile : constants.simpleConfigStubFile
45-
let stub = utils.readFile(stubFile)
46-
47-
noComments && (stub = utils.stripBlockComments(stub))
39+
const stub = utils.readFile(stubFile)
4840

4941
utils.writeFile(file, stub)
5042

src/cli/utils.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import chalk from 'chalk'
22
import { ensureFileSync, existsSync, outputFileSync, readFileSync } from 'fs-extra'
33
import { findKey, mapValues, trimStart } from 'lodash'
4-
import stripComments from 'strip-comments'
54

65
import * as emoji from './emoji'
76
import packageJson from '../../package.json'
@@ -122,17 +121,3 @@ export function writeFile(path, content) {
122121

123122
return outputFileSync(path, content)
124123
}
125-
126-
/**
127-
* Strips block comments from input string. Consolidates multiple line breaks.
128-
*
129-
* @param {string} input
130-
* @return {string}
131-
*/
132-
export function stripBlockComments(input) {
133-
return stripComments
134-
.block(input, { keepProtected: true })
135-
.replace(/\n\s*\n\s*\n/g, '\n\n') // Strip unnecessary line breaks
136-
.trim()
137-
.concat('\n')
138-
}

yarn.lock

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -945,12 +945,6 @@ aws4@^1.8.0:
945945
version "1.8.0"
946946
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
947947

948-
babel-extract-comments@^1.0.0:
949-
version "1.0.0"
950-
resolved "https://registry.yarnpkg.com/babel-extract-comments/-/babel-extract-comments-1.0.0.tgz#0a2aedf81417ed391b85e18b4614e693a0351a21"
951-
dependencies:
952-
babylon "^6.18.0"
953-
954948
babel-jest@^24.3.1, babel-jest@^24.5.0:
955949
version "24.5.0"
956950
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.5.0.tgz#0ea042789810c2bec9065f7c8ab4dc18e1d28559"
@@ -977,35 +971,13 @@ babel-plugin-jest-hoist@^24.3.0:
977971
dependencies:
978972
"@types/babel__traverse" "^7.0.6"
979973

980-
babel-plugin-syntax-object-rest-spread@^6.8.0:
981-
version "6.13.0"
982-
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
983-
984-
babel-plugin-transform-object-rest-spread@^6.26.0:
985-
version "6.26.0"
986-
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06"
987-
dependencies:
988-
babel-plugin-syntax-object-rest-spread "^6.8.0"
989-
babel-runtime "^6.26.0"
990-
991974
babel-preset-jest@^24.3.0:
992975
version "24.3.0"
993976
resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.3.0.tgz#db88497e18869f15b24d9c0e547d8e0ab950796d"
994977
dependencies:
995978
"@babel/plugin-syntax-object-rest-spread" "^7.0.0"
996979
babel-plugin-jest-hoist "^24.3.0"
997980

998-
babel-runtime@^6.26.0:
999-
version "6.26.0"
1000-
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
1001-
dependencies:
1002-
core-js "^2.4.0"
1003-
regenerator-runtime "^0.11.0"
1004-
1005-
babylon@^6.18.0:
1006-
version "6.18.0"
1007-
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
1008-
1009981
balanced-match@^1.0.0:
1010982
version "1.0.0"
1011983
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
@@ -1288,10 +1260,6 @@ copy-descriptor@^0.1.0:
12881260
version "0.1.1"
12891261
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
12901262

1291-
core-js@^2.4.0:
1292-
version "2.5.6"
1293-
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.6.tgz#0fe6d45bf3cac3ac364a9d72de7576f4eb221b9d"
1294-
12951263
core-js@^2.5.7:
12961264
version "2.6.5"
12971265
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895"
@@ -3645,10 +3613,6 @@ regenerate@^1.4.0:
36453613
version "1.4.0"
36463614
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
36473615

3648-
regenerator-runtime@^0.11.0:
3649-
version "0.11.1"
3650-
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
3651-
36523616
regenerator-runtime@^0.12.0:
36533617
version "0.12.1"
36543618
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"
@@ -4099,13 +4063,6 @@ strip-bom@^3.0.0:
40994063
version "3.0.0"
41004064
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
41014065

4102-
strip-comments@^1.0.2:
4103-
version "1.0.2"
4104-
resolved "https://registry.yarnpkg.com/strip-comments/-/strip-comments-1.0.2.tgz#82b9c45e7f05873bee53f37168af930aa368679d"
4105-
dependencies:
4106-
babel-extract-comments "^1.0.0"
4107-
babel-plugin-transform-object-rest-spread "^6.26.0"
4108-
41094066
strip-eof@^1.0.0:
41104067
version "1.0.0"
41114068
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"

0 commit comments

Comments
 (0)