From 78cf6001a058afa65ca32c29c1831da00698bac0 Mon Sep 17 00:00:00 2001 From: Santana James Date: Thu, 25 May 2017 17:08:31 -0400 Subject: [PATCH 001/251] Allow passing a number to --poll to set poll interval --- README.md | 2 +- index.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 63b052f..3ba118c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ cat input.css | postcss [OPTIONS] > output.css |`-s, --syntax`|`{String}`|`undefined`|Custom PostCSS Syntax| |`-t, --stringifier`|`{String}`|`undefined`|Custom PostCSS Stringifier| |`-w, --watch`|`{Boolean}`|`false`|Enable Watch Mode| -|`--poll`|`{Boolean}`|`false`|Use polling for file watching| +|`--poll`|`{Boolean|Number}`|`100`|Use polling for file watching. Can optionally pass polling interval; default 100 ms| |`-u, --use`|`{Array}`|`[]`|PostCSS Plugins| |`-m, --map`|`{Boolean}`|`{ inline: true }`|External Sourcemaps| |`--no-map`|`{Boolean}`|`false`|Disable Sourcemaps| diff --git a/index.js b/index.js index aa9d5ed..5263e15 100644 --- a/index.js +++ b/index.js @@ -92,8 +92,7 @@ Usage: type: 'boolean' }) .option('poll', { - desc: 'Use polling for file watching', - type: 'boolean' + desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', }) .option('x', { alias: 'ext', @@ -196,7 +195,10 @@ Promise.resolve() if (argv.watch) { const watcher = chokidar.watch( input.concat(dependencies(results)), - { usePolling: argv.poll } + { + usePolling: argv.poll, + interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100 + } ) if (config.file) watcher.add(config.file) From f8c322795a0e0cc9e454d7dea6b44c9fcb2ebc2d Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 10 Jun 2017 11:36:05 -0400 Subject: [PATCH 002/251] Fix lint error --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5263e15..226b6d9 100644 --- a/index.js +++ b/index.js @@ -92,7 +92,7 @@ Usage: type: 'boolean' }) .option('poll', { - desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', + desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms' }) .option('x', { alias: 'ext', From 6a1d7aff1f7ee058941790e5c9a24e1dcfa67640 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 10 Jun 2017 11:37:41 -0400 Subject: [PATCH 003/251] Upgrade postcss-reporter to ^4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 04cd8d4..290874d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "ora": "^1.1.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", - "postcss-reporter": "^3.0.0", + "postcss-reporter": "^4.0.0", "read-cache": "^1.0.0", "yargs": "^8.0.1" }, From 71a8aff0829b2d909b912f30252592ef7c8847dc Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 10 Jun 2017 11:42:19 -0400 Subject: [PATCH 004/251] Update devDeps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 290874d..d11efe9 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "devDependencies": { "ava": "^0.19.1", "coveralls": "^2.12.0", - "nyc": "^10.1.2", - "postcss-import": "^9.1.0", + "nyc": "^11.0.2", + "postcss-import": "^10.0.0", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" From e7023d2f5db86e6bf4cd3c9629db2383a4bef544 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 10 Jun 2017 11:44:35 -0400 Subject: [PATCH 005/251] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a7199e..2cbaecd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +4.1.0 / 2017-06-10 +================== + +- Can now pass a number to `--poll` to set poll interval +- Updated `postcss-reporter` dependency to v4.0.0 + 4.0.0 / 2017-05-09 ================== From 1dd64080a6fdda2f434789ed9abdd010d817ed1e Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 10 Jun 2017 11:44:46 -0400 Subject: [PATCH 006/251] 4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d11efe9..16ff408 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "4.0.0", + "version": "4.1.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 3c90a48b4d00d18d4c304079738ca7ba5e500af7 Mon Sep 17 00:00:00 2001 From: Eric Irish Date: Tue, 13 Jun 2017 11:13:18 -0500 Subject: [PATCH 007/251] Fix flags table --poll documentation (#138) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ba118c..b107bf2 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ cat input.css | postcss [OPTIONS] > output.css |`-s, --syntax`|`{String}`|`undefined`|Custom PostCSS Syntax| |`-t, --stringifier`|`{String}`|`undefined`|Custom PostCSS Stringifier| |`-w, --watch`|`{Boolean}`|`false`|Enable Watch Mode| -|`--poll`|`{Boolean|Number}`|`100`|Use polling for file watching. Can optionally pass polling interval; default 100 ms| +|`--poll`|`{Boolean\|Number}`|`100`|Use polling for file watching. Can optionally pass polling interval; default 100 ms| |`-u, --use`|`{Array}`|`[]`|PostCSS Plugins| |`-m, --map`|`{Boolean}`|`{ inline: true }`|External Sourcemaps| |`--no-map`|`{Boolean}`|`false`|Disable Sourcemaps| From dc03d510de936b8d14ac98a70cf18211423cee56 Mon Sep 17 00:00:00 2001 From: cho-leukeleu Date: Mon, 19 Jun 2017 16:13:54 +0200 Subject: [PATCH 008/251] Fix syntax error in docs (#141) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b107bf2..4e5c5f9 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ module.exports = (ctx) => ({ map: ctx.options.map, parser: ctx.file.extname === '.sss' ? 'sugarss' : false, plugins: { - 'postcss-import': { root: ctx.file.dirname }), + 'postcss-import': { root: ctx.file.dirname }, 'cssnano': ctx.env === 'production' ? {} : false } }) From d0f806903373a120a094b0ffb4ae486d85e80d4d Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 15 Jul 2017 14:55:14 -0400 Subject: [PATCH 009/251] Use pretty-hrtime for time formatting --- index.js | 5 +++-- package.json | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 226b6d9..ce712fd 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const fs = require('fs-extra') const path = require('path') const ora = require('ora') +const prettyHrtime = require('pretty-hrtime') const stdin = require('get-stdin') const read = require('read-cache') const chalk = require('chalk') @@ -326,7 +327,7 @@ function css (css, file) { } } else { spinner.text = chalk.bold.green( - `Finished ${relativePath} (${Math.round(process.hrtime(time)[1] / 1e6)}ms)` + `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` ) spinner.succeed() return process.stdout.write(result.css, 'utf8') @@ -335,7 +336,7 @@ function css (css, file) { return Promise.all(tasks) .then(() => { spinner.text = chalk.bold.green( - `Finished ${relativePath} (${Math.round(process.hrtime(time)[1] / 1e6)}ms)` + `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` ) if (result.warnings().length) { spinner.fail() diff --git a/package.json b/package.json index 16ff408..d9a9ece 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", "postcss-reporter": "^4.0.0", + "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "yargs": "^8.0.1" }, From d07e9f79bd48c0894a560d43586699256cdd7590 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 15 Jul 2017 14:33:51 -0400 Subject: [PATCH 010/251] Switch from standard to eslint + prettier --- .eslintrc.yaml | 10 ++ index.js | 219 +++++++++++++++++++++++------------------- lib/depGraph.js | 1 + package.json | 6 +- test/.eslintrc.yaml | 3 + test/base.js | 18 ++-- test/cli.js | 20 ++-- test/config.js | 28 +++--- test/dir.js | 27 ++---- test/error.js | 76 +++++++-------- test/ext.js | 19 ++-- test/helpers/clean.js | 12 +-- test/helpers/cli.js | 12 +-- test/helpers/env.js | 23 ++--- test/helpers/read.js | 4 +- test/helpers/tmp.js | 4 +- test/map.js | 43 +++++---- test/misc.js | 10 +- test/parser.js | 23 ++--- test/replace.js | 22 ++--- test/stdin.js | 8 +- test/stdout.js | 12 +-- test/stringifier.js | 23 ++--- test/syntax.js | 23 ++--- test/use.js | 23 ++--- test/watch.js | 120 +++++++++++------------ 26 files changed, 387 insertions(+), 402 deletions(-) create mode 100644 .eslintrc.yaml create mode 100644 test/.eslintrc.yaml diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 0000000..ae169c8 --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,10 @@ +env: + node: true +extends: problems +plugins: + - prettier +rules: + prettier/prettier: + - error + - { semi: false, singleQuote: true } + no-console: off diff --git a/index.js b/index.js index ce712fd..5d9903b 100644 --- a/index.js +++ b/index.js @@ -47,11 +47,11 @@ const version = () => { const argv = require('yargs') .usage( -`${chalk.bold.red(logo)} + `${chalk.bold.red(logo)} Usage: $0 [input.css] [OPTIONS] [--output|-o output.css] [--watch]` -) + ) .option('o', { alias: 'output', desc: 'Output file', @@ -93,14 +93,15 @@ Usage: type: 'boolean' }) .option('poll', { - desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms' + desc: + 'Use polling for file watching. Can optionally pass polling interval; default 100 ms' }) .option('x', { alias: 'ext', desc: 'Override the output file extension', type: 'string', - coerce (ext) { - if (ext.indexOf('.') !== 0) return '.' + ext + coerce(ext) { + if (ext.indexOf('.') !== 0) return `.${ext}` return ext } }) @@ -111,7 +112,8 @@ Usage: }) .option('b', { alias: 'base', - desc: 'Mirror the directory structure relative to this path in the output directory, this only works together with --dir', + desc: + 'Mirror the directory structure relative to this path in the output directory, this only works together with --dir', type: 'string' }) .option('c', { @@ -120,25 +122,29 @@ Usage: type: 'string' }) .alias('m', 'map') - .describe('m', 'Create an external sourcemap') - .describe('no-map', 'Disable the default inline sourcemaps') - .version(version).alias('v', 'version') - .help('h').alias('h', 'help') + .describe('m', 'Create an external sourcemap') + .describe('no-map', 'Disable the default inline sourcemaps') + .version(version) + .alias('v', 'version') + .help('h') + .alias('h', 'help') .example('$0 input.css -o output.css', 'Basic usage') - .example('cat input.css | $0 -u autoprefixer > output.css', 'Piping input & output') + .example( + 'cat input.css | $0 -u autoprefixer > output.css', + 'Piping input & output' + ) .epilog( -`If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. + `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. If there are multiple input files, the --dir or --replace option must be passed. For more details, please see https://github.com/postcss/postcss-cli` - ) - .argv + ).argv -let dir = argv.dir +const dir = argv.dir let input = argv._ -let output = argv.output +const output = argv.output if (argv.map) argv.map = { inline: false } @@ -152,13 +158,13 @@ let config = { stringifier: argv.stringifier ? require(argv.stringifier) : undefined }, plugins: argv.use - ? argv.use.map((plugin) => { - try { - return require(plugin)() - } catch (e) { - error(`Plugin Error: Cannot find module '${plugin}'`) - } - }) + ? argv.use.map(plugin => { + try { + return require(plugin)() + } catch (e) { + return error(`Plugin Error: Cannot find module '${plugin}'`) + } + }) : [] } @@ -169,7 +175,11 @@ Promise.resolve() .then(() => { if (input && input.length) return globber(input) - if (argv.replace || argv.dir) error('Input Error: Cannot use --dir or --replace when reading from stdin') + if (argv.replace || argv.dir) { + error( + 'Input Error: Cannot use --dir or --replace when reading from stdin' + ) + } if (argv.watch) { error('Input Error: Cannot run in watch mode when reading from stdin') @@ -177,13 +187,15 @@ Promise.resolve() return ['stdin'] }) - .then((i) => { + .then(i => { if (!i || !i.length) { error('Input Error: You must pass a valid list of files to parse') } if (i.length > 1 && !argv.dir && !argv.replace) { - error('Input Error: Must use --dir or --replace with multiple input files') + error( + 'Input Error: Must use --dir or --replace with multiple input files' + ) } if (i[0] !== 'stdin') i = i.map(i => path.resolve(i)) @@ -192,21 +204,20 @@ Promise.resolve() return files(input) }) - .then((results) => { + .then(results => { if (argv.watch) { - const watcher = chokidar.watch( - input.concat(dependencies(results)), - { - usePolling: argv.poll, - interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100 - } - ) + const watcher = chokidar.watch(input.concat(dependencies(results)), { + usePolling: argv.poll, + interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100 + }) if (config.file) watcher.add(config.file) watcher - .on('ready', (file) => console.warn(chalk.bold.cyan('Waiting for file changes...'))) - .on('change', (file) => { + .on('ready', () => { + console.warn(chalk.bold.cyan('Waiting for file changes...')) + }) + .on('change', file => { let recompile = [] if (~input.indexOf(file)) recompile.push(file) @@ -218,47 +229,51 @@ Promise.resolve() if (!recompile.length) recompile = input return files(recompile) - .then((results) => watcher.add(dependencies(results))) - .then(() => console.warn(chalk.bold.cyan('Waiting for file changes...'))) + .then(results => watcher.add(dependencies(results))) + .then(() => { + console.warn(chalk.bold.cyan('Waiting for file changes...')) + }) .catch(error) }) } }) .catch(error) -function rc (ctx, path) { +function rc(ctx, path) { if (argv.use) return Promise.resolve() return postcssrc(ctx, path) - .then((rc) => { + .then(rc => { if (rc.options.from || rc.options.to) { - error('Config Error: Can not set from or to options in config file, use CLI arguments instead') + error( + 'Config Error: Can not set from or to options in config file, use CLI arguments instead' + ) } config = rc }) - .catch((err) => { + .catch(err => { if (err.message.indexOf('No PostCSS Config found') === -1) throw err }) } -function files (files) { - if (typeof files === 'string') files = [ files ] +function files(files) { + if (typeof files === 'string') files = [files] - return Promise.all(files.map((file) => { - if (file === 'stdin') { - return stdin() - .then((content) => { + return Promise.all( + files.map(file => { + if (file === 'stdin') { + return stdin().then(content => { if (!content) return error('Input Error: Did not receive any STDIN') return css(content, 'stdin') }) - } + } - return read(file) - .then((content) => css(content, file)) - })) + return read(file).then(content => css(content, file)) + }) + ) } -function css (css, file) { +function css(css, file) { const ctx = { options: config.options } if (file !== 'stdin') { @@ -271,7 +286,8 @@ function css (css, file) { if (!argv.config) argv.config = path.dirname(file) } - const relativePath = file !== 'stdin' ? path.relative(path.resolve(), file) : file + const relativePath = + file !== 'stdin' ? path.relative(path.resolve(), file) : file if (!argv.config) argv.config = process.cwd() @@ -282,7 +298,7 @@ function css (css, file) { return rc(ctx, argv.config) .then(() => { - let options = config.options + const options = config.options if (file === 'stdin' && output) file = output @@ -290,11 +306,13 @@ function css (css, file) { options.from = file === 'stdin' ? path.join(process.cwd(), 'stdin') : file if (output || dir || argv.replace) { - options.to = output || (argv.replace ? file : path.join(dir, argv.base ? file.replace(path.resolve(argv.base), '') : path.basename(file))) + const base = argv.base + ? file.replace(path.resolve(argv.base), '') + : path.basename(file) + options.to = output || (argv.replace ? file : path.join(dir, base)) if (argv.ext) { - options.to = options.to - .replace(path.extname(options.to), argv.ext) + options.to = options.to.replace(path.extname(options.to), argv.ext) } options.to = path.resolve(options.to) @@ -302,74 +320,73 @@ function css (css, file) { if (!options.to && config.options.map && !config.options.map.inline) { spinner.fail() - error('Output Error: Cannot output external sourcemaps when writing to STDOUT') + error( + 'Output Error: Cannot output external sourcemaps when writing to STDOUT' + ) } - return postcss(config.plugins) - .process(css, options) - .then((result) => { - const tasks = [] - - if (options.to) { - tasks.push(fs.outputFile(options.to, result.css)) - - if (result.map) { - tasks.push( - fs.outputFile( - options.to - .replace( - path.extname(options.to), - path.extname(options.to) + '.map' - ), - result.map - ) + return postcss(config.plugins).process(css, options).then(result => { + const tasks = [] + + if (options.to) { + tasks.push(fs.outputFile(options.to, result.css)) + + if (result.map) { + tasks.push( + fs.outputFile( + options.to.replace( + path.extname(options.to), + `${path.extname(options.to)}.map` + ), + result.map ) - } - } else { - spinner.text = chalk.bold.green( - `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` ) - spinner.succeed() - return process.stdout.write(result.css, 'utf8') } + } else { + spinner.text = chalk.bold.green( + `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` + ) + spinner.succeed() + return process.stdout.write(result.css, 'utf8') + } - return Promise.all(tasks) - .then(() => { - spinner.text = chalk.bold.green( - `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` - ) - if (result.warnings().length) { - spinner.fail() - console.warn(reporter(result)) - } else spinner.succeed() + return Promise.all(tasks).then(() => { + spinner.text = chalk.bold.green( + `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` + ) + if (result.warnings().length) { + spinner.fail() + console.warn(reporter(result)) + } else spinner.succeed() - return result - }) + return result }) - }).catch((err) => { + }) + }) + .catch(err => { spinner.fail() throw err }) } -function dependencies (results) { - if (!Array.isArray(results)) results = [ results ] +function dependencies(results) { + if (!Array.isArray(results)) results = [results] const messages = [] - results.forEach((result) => { + results.forEach(result => { if (result.messages <= 0) return result.messages - .filter((msg) => msg.type === 'dependency' ? msg : '') + .filter(msg => (msg.type === 'dependency' ? msg : '')) .map(depGraph.add) - .forEach((dependency) => messages.push(dependency.file)) + .forEach(dependency => messages.push(dependency.file)) }) return messages } -function error (err) { +function error(err) { if (typeof err === 'string') { spinner.fail(chalk.bold.red(err)) } else if (err.name === 'CssSyntaxError') { diff --git a/lib/depGraph.js b/lib/depGraph.js index 2b54a70..19bd6b7 100644 --- a/lib/depGraph.js +++ b/lib/depGraph.js @@ -1,3 +1,4 @@ +'use strict' const path = require('path') const DepGraph = require('dependency-graph').DepGraph diff --git a/package.json b/package.json index d9a9ece..e0e73c1 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "scripts": { "clean": "node test/helpers/clean.js", - "lint": "standard", + "lint": "eslint .", "pretest": "npm run clean && npm run lint", "test": "nyc ava -v" }, @@ -33,8 +33,12 @@ "devDependencies": { "ava": "^0.19.1", "coveralls": "^2.12.0", + "eslint": "^4.2.0", + "eslint-config-problems": "0.0.2", + "eslint-plugin-prettier": "^2.1.2", "nyc": "^11.0.2", "postcss-import": "^10.0.0", + "prettier": "^1.5.3", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml new file mode 100644 index 0000000..066cdcd --- /dev/null +++ b/test/.eslintrc.yaml @@ -0,0 +1,3 @@ +parserOptions: + ecmaVersion: 2017 + sourceType: module diff --git a/test/base.js b/test/base.js index e55063b..5402d31 100644 --- a/test/base.js +++ b/test/base.js @@ -5,17 +5,17 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--base --dir works', async function (t) { +test('--base --dir works', async t => { const dir = tmp() - const { error, stderr } = await cli( - [ - 'test/fixtures/base/**/*.css', - '--dir', dir, - '--base', 'test/fixtures/base', - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/base/**/*.css', + '--dir', + dir, + '--base', + 'test/fixtures/base', + '--no-map' + ]) t.ifError(error, stderr) diff --git a/test/cli.js b/test/cli.js index b97ec6b..87ed9f9 100644 --- a/test/cli.js +++ b/test/cli.js @@ -4,21 +4,17 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('works with defaults', async function (t) { +test('works with defaults', async t => { const output = tmp('output.css') - const { error, stderr } = await cli( - [ - 'test/fixtures/a.css', - '-o', output, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/a.css', + '-o', + output, + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(output), - await read('test/fixtures/a.css') - ) + t.is(await read(output), await read('test/fixtures/a.css')) }) diff --git a/test/config.js b/test/config.js index e5ccd00..f9d5c43 100644 --- a/test/config.js +++ b/test/config.js @@ -6,7 +6,7 @@ import ENV from './helpers/env.js' import cli from './helpers/cli.js' import read from './helpers/read.js' -test('supports common config', async function (t) { +test('supports common config', async t => { const env = `module.exports = { plugins: [ require('postcss-import')() @@ -28,7 +28,7 @@ test('supports common config', async function (t) { ) }) -test("doesn't error on empty config", async function (t) { +test("doesn't error on empty config", async t => { const env = `module.exports = {}` const dir = await ENV(env, ['a.css']) @@ -46,32 +46,32 @@ test("doesn't error on empty config", async function (t) { ) }) -test('errors if `to` is set', async function (t) { +test('errors if `to` is set', async t => { const env = `module.exports = { to: 'out.css' }` const dir = await ENV(env, ['a.css']) - const { stderr } = await cli( - ['a.css', '-o', 'output.css', '--no-map'], - dir - ) + const { stderr } = await cli(['a.css', '-o', 'output.css', '--no-map'], dir) - t.regex(stderr, /Config Error: Can not set from or to options in config file, use CLI arguments instead/) + t.regex( + stderr, + /Config Error: Can not set from or to options in config file, use CLI arguments instead/ + ) }) -test('errors if `from` is set', async function (t) { +test('errors if `from` is set', async t => { const env = `module.exports = { from: 'in.css' }` const dir = await ENV(env, ['a.css']) - const { stderr } = await cli( - ['a.css', '-o', 'output.css', '--no-map'], - dir - ) + const { stderr } = await cli(['a.css', '-o', 'output.css', '--no-map'], dir) - t.regex(stderr, /Config Error: Can not set from or to options in config file, use CLI arguments instead/) + t.regex( + stderr, + /Config Error: Can not set from or to options in config file, use CLI arguments instead/ + ) }) diff --git a/test/dir.js b/test/dir.js index 81d9d01..8f31d35 100644 --- a/test/dir.js +++ b/test/dir.js @@ -5,27 +5,20 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--dir works', async function (t) { +test('--dir works', async t => { const dir = tmp() - const { error, stderr } = await cli( - [ - 'test/fixtures/a.css', - 'test/fixtures/b.css', - '--dir', dir, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/a.css', + 'test/fixtures/b.css', + '--dir', + dir, + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(path.join(dir, 'a.css')), - await read('test/fixtures/a.css') - ) + t.is(await read(path.join(dir, 'a.css')), await read('test/fixtures/a.css')) - t.is( - await read(path.join(dir, 'b.css')), - await read('test/fixtures/b.css') - ) + t.is(await read(path.join(dir, 'b.css')), await read('test/fixtures/b.css')) }) diff --git a/test/error.js b/test/error.js index 72929a2..1d1a097 100644 --- a/test/error.js +++ b/test/error.js @@ -3,72 +3,64 @@ import test from 'ava' import tmp from './helpers/tmp.js' import cli from './helpers/cli.js' -test('multiple input files && --output', (t) => { - return cli( - [ - 'test/fixtures/*.css', - '-o', tmp() - ] - ) - .then(({ err, code }) => { +test('multiple input files && --output', t => { + return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ err, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(err.toString(), /Input Error: Must use --dir or --replace/) }) }) -test('multiple input files && writing to stdout', (t) => { - return cli(['test/fixtures/*.css']) - .then(({ err, code }) => { +test('multiple input files && writing to stdout', t => { + return cli(['test/fixtures/*.css']).then(({ err, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(err.toString(), /Input Error: Must use --dir or --replace/) }) }) -test('--map && writing to stdout', (t) => { - return cli(['test/fixtures/a.css', '--map']) - .then(({ err, code }) => { +test('--map && writing to stdout', t => { + return cli(['test/fixtures/a.css', '--map']).then(({ err, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /Output Error: Cannot output external sourcemaps when writing to STDOUT/) + t.regex( + err.toString(), + /Output Error: Cannot output external sourcemaps when writing to STDOUT/ + ) }) }) -test.failing('invalid --config', (t) => { - return cli( - [ - 'test/fixtures/*.css', - '-c', 'test/postcss.config.js', - '-d', tmp() - ] - ) - .then(({ err, code }) => { +test.failing('invalid --config', t => { + return cli([ + 'test/fixtures/*.css', + '-c', + 'test/postcss.config.js', + '-d', + tmp() + ]).then(({ err, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(err.toString(), /ENOENT: no such file or directory/) }) }) -test('PluginError', (t) => { - return cli( - [ - 'test/fixtures/a.css', - '-u', 'postcss-plugin', - '-o', tmp() - ] - ) - .then(({ err, code }) => { +test('PluginError', t => { + return cli([ + 'test/fixtures/a.css', + '-u', + 'postcss-plugin', + '-o', + tmp() + ]).then(({ err, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(err.toString(), /Plugin Error: Cannot find module 'postcss-plugin'/) }) }) -test('CssSyntaxError', (t) => { - return cli( - [ - 'test/fixtures/a.css', - '-p', 'sugarss', - '-o', tmp() - ] - ) - .then(({ err, code }) => { +test('CssSyntaxError', t => { + return cli([ + 'test/fixtures/a.css', + '-p', + 'sugarss', + '-o', + tmp() + ]).then(({ err, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(err.toString(), /\[1:4] Unnecessary curly bracket/) }) diff --git a/test/ext.js b/test/ext.js index 10578cc..f24ada1 100644 --- a/test/ext.js +++ b/test/ext.js @@ -6,17 +6,18 @@ import path from 'path' import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' -test('--ext works', async function (t) { +test('--ext works', async t => { const dir = tmp() - const { error, stderr } = await cli( - [ - 'test/fixtures/a.sss', - '-p', 'sugarss', - '-d', dir, - '--ext', '.css' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/a.sss', + '-p', + 'sugarss', + '-d', + dir, + '--ext', + '.css' + ]) t.ifError(error, stderr) t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) diff --git a/test/helpers/clean.js b/test/helpers/clean.js index 4a9c929..6edfe98 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -1,13 +1,11 @@ -'use strict' - +'use strict' // eslint-disable-line const fs = require('fs-extra') Promise.all([ fs.emptyDir('./test/fixtures/.tmp/'), fs.remove('./coverage'), fs.remove('./.nyc_output') -]) - .catch(err => { - console.error(err) - process.exit(1) - }) +]).catch(err => { + console.error(err) + process.exit(1) +}) diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 4e55c2a..d6027ae 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,13 +1,12 @@ -'use strict' - import path from 'path' import { execFile } from 'child_process' -export default function (args, cwd) { - return new Promise((resolve) => { +export default function(args, cwd) { + return new Promise(resolve => { execFile( path.resolve('bin/postcss'), - args, { cwd }, + args, + { cwd }, (err, stdout, stderr) => { resolve({ code: err && err.code ? err.code : 0, @@ -15,6 +14,7 @@ export default function (args, cwd) { stdout, stderr }) - }) + } + ) }) } diff --git a/test/helpers/env.js b/test/helpers/env.js index d655628..32c78f8 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,26 +1,19 @@ -'use strict' - import fs from 'fs-extra' import path from 'path' import globby from 'globby' import tmp from './tmp.js' -export default function (config, fixtures) { +export default function(config, fixtures) { fixtures = fixtures || '**/*' - // fixtures = fixtures.map(p => path.join('test/fixtures', p)) const dir = tmp() - // Save promise in a const - const fixture = globby(fixtures, { cwd: 'test/fixtures' }) - .then((list) => { - return list.map((item) => { + + return Promise.all([ + globby(fixtures, { cwd: 'test/fixtures' }).then(list => { + return list.map(item => { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) - }) - // Save promise in a const - const rc = fs.outputFile( - path.join(dir, 'postcss.config.js'), config - ) - // Return a promise for dir when both tasks are done: - return Promise.all([ fixture, rc ]).then(() => dir) + }), + fs.outputFile(path.join(dir, 'postcss.config.js'), config) + ]).then(() => dir) } diff --git a/test/helpers/read.js b/test/helpers/read.js index 7526a61..59f727d 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,7 +1,5 @@ -'use strict' - import { readFile } from 'fs-extra' -export default function (path) { +export default function(path) { return readFile(path, 'utf8') } diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index 139d185..d05dec9 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,9 +1,7 @@ -'use strict' - import path from 'path' import uuid from 'uuid' -export default function (ext) { +export default function(ext) { ext = ext || '' return path.join('test/fixtures/.tmp', uuid(), ext) diff --git a/test/map.js b/test/map.js index e7862c0..c82946a 100644 --- a/test/map.js +++ b/test/map.js @@ -5,41 +5,50 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('inline maps are generated by default', async function (t) { +test('inline maps are generated by default', async t => { const output = tmp('output.css') - const { error, stderr } = await cli( - [ 'test/fixtures/import.css', '-u', 'postcss-import', '-o', output ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/import.css', + '-u', + 'postcss-import', + '-o', + output + ]) t.ifError(error, stderr) t.regex(await read(output), /\/*# sourceMappingURL=/) }) -test('--map generates external sourcemaps', async function (t) { +test('--map generates external sourcemaps', async t => { const output = tmp('output.css') - const { error, stderr } = await cli( - [ 'test/fixtures/import.css', '-u', 'postcss-import', '-o', output, '--map' ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/import.css', + '-u', + 'postcss-import', + '-o', + output, + '--map' + ]) t.ifError(error, stderr) t.truthy(await fs.pathExists(output.replace('.css', '.css.map'))) }) -test('--no-map disables internal sourcemaps', async function (t) { +test('--no-map disables internal sourcemaps', async t => { const output = tmp('output.css') - const { error, stderr } = await cli( - [ - 'test/fixtures/import.css', - '-u', 'postcss-import', - '-o', output, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/import.css', + '-u', + 'postcss-import', + '-o', + output, + '--no-map' + ]) t.ifError(error, stderr) t.notRegex(await read(output), /\/*# sourceMappingURL=/) diff --git a/test/misc.js b/test/misc.js index 3d02dde..4689ceb 100644 --- a/test/misc.js +++ b/test/misc.js @@ -2,17 +2,15 @@ import test from 'ava' import cli from './helpers/cli.js' -test('--help', async function (t) { +test('--help', async t => { const help = await cli(['--help']) t.ifError(help.error) - t.truthy( - help.stdout.length > 10, - 'expected --help to output a help message' - ) + t.truthy(help.stdout.length > 10, 'expected --help to output a help message') }) -test('--version', async function (t) { + +test('--version', async t => { const version = await cli(['--version']) t.ifError(version.error) diff --git a/test/parser.js b/test/parser.js index be3cad7..46211dc 100644 --- a/test/parser.js +++ b/test/parser.js @@ -4,22 +4,19 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--parser works', async function (t) { +test('--parser works', async t => { const output = tmp('output.css') - const { error, stderr } = await cli( - [ - 'test/fixtures/a.sss', - '-p', 'sugarss', - '-o', output, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/a.sss', + '-p', + 'sugarss', + '-o', + output, + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(output), - await read('test/fixtures/s.css') - ) + t.is(await read(output), await read('test/fixtures/s.css')) }) diff --git a/test/replace.js b/test/replace.js index c2a1c7e..38127ae 100644 --- a/test/replace.js +++ b/test/replace.js @@ -7,7 +7,7 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--replace works', async function (t) { +test('--replace works', async t => { const dir = tmp() const output = path.join(dir, 'output.css') @@ -17,19 +17,15 @@ test('--replace works', async function (t) { fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')) ]) - const { error, stderr } = await cli( - [ - output, - '--replace', - '-u', 'postcss-import', - '--no-map' - ] - ) + const { error, stderr } = await cli([ + output, + '--replace', + '-u', + 'postcss-import', + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(output), - await read('test/fixtures/a.css') - ) + t.is(await read(output), await read('test/fixtures/a.css')) }) diff --git a/test/stdin.js b/test/stdin.js index 78dd855..7e6907a 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -7,17 +7,17 @@ import { execFile } from 'child_process' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test.cb('reads from stdin', (t) => { +test.cb('reads from stdin', t => { const output = tmp('output.css') - let cp = execFile( + const cp = execFile( path.resolve('bin/postcss'), ['-o', output, '--no-map'], (error, stdout, stderr) => { if (error) t.end(error, stderr) - Promise.all([ read(output), read('test/fixtures/a.css') ]) - .then(([ a, e ]) => { + Promise.all([read(output), read('test/fixtures/a.css')]) + .then(([a, e]) => { t.is(a, e) t.end() }) diff --git a/test/stdout.js b/test/stdout.js index 31433c2..5033911 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -6,19 +6,15 @@ import { execFile } from 'child_process' import read from './helpers/read.js' -test.cb('writes to stdout', function (t) { +test.cb('writes to stdout', t => { const cp = execFile( path.resolve('bin/postcss'), - [ - '-p', 'sugarss', - '-u', 'postcss-import', - '--no-map' - ], + ['-p', 'sugarss', '-u', 'postcss-import', '--no-map'], (error, stdout, stderr) => { if (error) t.end(error, stderr) - Promise.all([ stdout, read('test/fixtures/s.css') ]) - .then(([ a, e ]) => { + Promise.all([stdout, read('test/fixtures/s.css')]) + .then(([a, e]) => { t.is(a, e) t.end() }) diff --git a/test/stringifier.js b/test/stringifier.js index 55e7d68..0eb0d74 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -4,22 +4,19 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--stringifier works', async function (t) { +test('--stringifier works', async t => { const output = tmp('output.sss') - const { error, stderr } = await cli( - [ - 'test/fixtures/a.css', - '-t', 'sugarss', - '-o', output, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/a.css', + '-t', + 'sugarss', + '-o', + output, + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(output), - await read('test/fixtures/a.sss') - ) + t.is(await read(output), await read('test/fixtures/a.sss')) }) diff --git a/test/syntax.js b/test/syntax.js index 272b932..78a496d 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -4,22 +4,19 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--syntax works', async function (t) { +test('--syntax works', async t => { const output = tmp('output.sss') - const { error, stderr } = await cli( - [ - 'test/fixtures/a.sss', - '-s', 'sugarss', - '-o', output, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/a.sss', + '-s', + 'sugarss', + '-o', + output, + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(output), - await read('test/fixtures/a.sss') - ) + t.is(await read(output), await read('test/fixtures/a.sss')) }) diff --git a/test/use.js b/test/use.js index 6b8a5f6..c6052e0 100644 --- a/test/use.js +++ b/test/use.js @@ -4,22 +4,19 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' -test('--use works', async function (t) { +test('--use works', async t => { const output = tmp('i.css') - const { error, stderr } = await cli( - [ - 'test/fixtures/import.css', - '-u', 'postcss-import', - '-o', output, - '--no-map' - ] - ) + const { error, stderr } = await cli([ + 'test/fixtures/import.css', + '-u', + 'postcss-import', + '-o', + output, + '--no-map' + ]) t.ifError(error, stderr) - t.is( - await read(output), - await read('test/fixtures/a.css') - ) + t.is(await read(output), await read('test/fixtures/a.css')) }) diff --git a/test/watch.js b/test/watch.js index b02a20f..2ac43fd 100644 --- a/test/watch.js +++ b/test/watch.js @@ -8,14 +8,14 @@ import chokidar from 'chokidar' import ENV from './helpers/env.js' import read from './helpers/read.js' -test.cb('--watch works', function (t) { +test.cb('--watch works', t => { let cp t.plan(2) ENV('', ['a.css']) - .then((dir) => { - // Init watcher: + .then(dir => { + // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, @@ -23,7 +23,7 @@ test.cb('--watch works', function (t) { }) // On the first output: - watcher.on('add', (p) => { + watcher.on('add', p => { // Assert, then change the source file if (p === 'output.css') { isEqual(p, 'test/fixtures/a.css') @@ -34,11 +34,9 @@ test.cb('--watch works', function (t) { }) // When the change is picked up: - watcher.on('change', (p) => { + watcher.on('change', p => { if (p === 'output.css') { - isEqual(p, 'test/fixtures/b.css') - .then(() => done()) - .catch(done) + isEqual(p, 'test/fixtures/b.css').then(() => done()).catch(done) } }) @@ -50,19 +48,20 @@ test.cb('--watch works', function (t) { { cwd: dir } ) cp.on('error', t.end) - cp.on('exit', code => { if (code) t.end(code) }) + cp.on('exit', code => { + if (code) t.end(code) + }) }) // Helper functions: - function isEqual (p, expected) { + function isEqual(p, expected) { return Promise.all([ read(path.join(dir, p)), read(expected) - ]) - .then(([a, e]) => t.is(a, e)) + ]).then(([a, e]) => t.is(a, e)) } - function done (err) { + function done(err) { try { cp.kill() } catch (e) {} @@ -70,19 +69,19 @@ test.cb('--watch works', function (t) { t.end(err) } }) - .catch(t.end) + .catch(t.end) // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) -test.cb('--watch postcss.config.js', function (t) { +test.cb('--watch postcss.config.js', t => { let cp t.plan(2) ENV('module.exports = {}', ['import.css', 'a.css']) - .then((dir) => { + .then(dir => { // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, @@ -91,11 +90,11 @@ test.cb('--watch postcss.config.js', function (t) { }) // On the first output: - watcher.on('add', (p) => { + watcher.on('add', p => { // Assert, then change the source file if (p === 'output.css') { read(path.join(dir, p)) - .then((css) => { + .then(css => { t.is(css, '@import "./a.css";\n') return fs.writeFile( @@ -112,11 +111,9 @@ test.cb('--watch postcss.config.js', function (t) { }) // When the change is picked up: - watcher.on('change', (p) => { + watcher.on('change', p => { if (p === 'output.css') { - isEqual(p, 'test/fixtures/a.css') - .then(() => done()) - .catch(done) + isEqual(p, 'test/fixtures/a.css').then(() => done()).catch(done) } }) @@ -124,26 +121,25 @@ test.cb('--watch postcss.config.js', function (t) { watcher.on('ready', () => { cp = execFile( path.resolve('bin/postcss'), - [ - 'import.css', - '-o', 'output.css', - '-w', - '--no-map' - ], + ['import.css', '-o', 'output.css', '-w', '--no-map'], { cwd: dir } ) cp.on('error', t.end) - cp.on('exit', (code) => { if (code) t.end(code) }) + cp.on('exit', code => { + if (code) t.end(code) + }) }) // Helper functions: - function isEqual (p, expected) { - return Promise.all([ read(path.join(dir, p)), read(expected) ]) - .then(([a, e]) => t.is(a, e)) + function isEqual(p, expected) { + return Promise.all([ + read(path.join(dir, p)), + read(expected) + ]).then(([a, e]) => t.is(a, e)) } - function done (err) { + function done(err) { try { cp.kill() } catch (e) {} @@ -151,20 +147,20 @@ test.cb('--watch postcss.config.js', function (t) { t.end(err) } }) - .catch(t.end) + .catch(t.end) // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) -test.cb('--watch dependencies', function (t) { +test.cb('--watch dependencies', t => { let cp t.plan(2) ENV('', ['import.css', 'a.css']) - .then((dir) => { - // Init watcher: + .then(dir => { + // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, @@ -172,7 +168,7 @@ test.cb('--watch dependencies', function (t) { }) // On the first output: - watcher.on('add', (p) => { + watcher.on('add', p => { // Assert, then change the source file if (p === 'output.css') { isEqual(p, 'test/fixtures/a.css') @@ -183,11 +179,9 @@ test.cb('--watch dependencies', function (t) { }) // When the change is picked up: - watcher.on('change', (p) => { + watcher.on('change', p => { if (p === 'output.css') { - isEqual(p, 'test/fixtures/b.css') - .then(() => done()) - .catch(done) + isEqual(p, 'test/fixtures/b.css').then(() => done()).catch(done) } }) @@ -197,8 +191,10 @@ test.cb('--watch dependencies', function (t) { path.resolve('bin/postcss'), [ 'import.css', - '-o', 'output.css', - '-u', 'postcss-import', + '-o', + 'output.css', + '-u', + 'postcss-import', '-w', '--no-map' ], @@ -206,56 +202,54 @@ test.cb('--watch dependencies', function (t) { ) cp.on('error', t.end) - cp.on('exit', code => { if (code) t.end(code) }) + cp.on('exit', code => { + if (code) t.end(code) + }) }) // Helper functions: - function isEqual (p, expected) { - return Promise.all([read(path.join(dir, p)), read(expected)]) - .then(([a, e]) => t.is(a, e)) + function isEqual(p, expected) { + return Promise.all([ + read(path.join(dir, p)), + read(expected) + ]).then(([a, e]) => t.is(a, e)) } - function done (err) { + function done(err) { try { cp.kill() } catch (e) {} t.end(err) } }) - .catch(t.end) + .catch(t.end) // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) -test.cb("--watch doesn't exit on CssSyntaxError", function (t) { +test.cb("--watch doesn't exit on CssSyntaxError", t => { t.plan(0) ENV('', ['a.css']) - .then((dir) => { + .then(dir => { // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, awaitWriteFinish: true }) - watcher.on('add', (p) => { + watcher.on('add', p => { if (p === 'output.css') { // Change to invalid CSS - fs.writeFile(path.join(dir, 'a.css'), '.a { color: red') - .catch(done) + fs.writeFile(path.join(dir, 'a.css'), '.a { color: red').catch(done) } }) let killed = false - let cp = execFile( + const cp = execFile( path.resolve('bin/postcss'), - [ - 'a.css', - '-o', 'output.css', - '-w', - '--no-map' - ], + ['a.css', '-o', 'output.css', '-w', '--no-map'], { cwd: dir } ) cp.on('error', t.end) @@ -273,7 +267,7 @@ test.cb("--watch doesn't exit on CssSyntaxError", function (t) { done() }) - function done (err) { + function done(err) { try { cp.kill() } catch (e) {} From adb1acd996b1dc245c524ba3a6cd3dca7d32567f Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 15 Jul 2017 15:21:41 -0400 Subject: [PATCH 011/251] Modify npm scripts - Auto-format in npm test - Run seperate script on the CI --- .travis.yml | 2 ++ appveyor.yml | 2 +- package.json | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58d5476..c7f034b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,7 @@ node_js: - node - 6 - 4 +script: + - npm run ci after_success: - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' diff --git a/appveyor.yml b/appveyor.yml index 2f9467a..f454e5d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,4 +15,4 @@ install: test_script: - node --version - npm --version - - npm test + - npm run ci diff --git a/package.json b/package.json index e0e73c1..1b78248 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "postcss": "./bin/postcss" }, "scripts": { + "ci": "eslint . && nyc ava -v", "clean": "node test/helpers/clean.js", - "lint": "eslint .", - "pretest": "npm run clean && npm run lint", + "format": "eslint . --fix", + "pretest": "npm run clean && npm run format", "test": "nyc ava -v" }, "dependencies": { @@ -37,6 +38,7 @@ "eslint-config-problems": "0.0.2", "eslint-plugin-prettier": "^2.1.2", "nyc": "^11.0.2", + "per-env": "^1.0.2", "postcss-import": "^10.0.0", "prettier": "^1.5.3", "standard": "^10.0.2", From 2322cb8d8d8080e9ac00471cd32fd2d6e8515013 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 15 Jul 2017 15:23:26 -0400 Subject: [PATCH 012/251] Move args parsing to seperate file --- index.js | 125 +-------------------------------------------------- lib/args.js | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 124 deletions(-) create mode 100644 lib/args.js diff --git a/index.js b/index.js index 5d9903b..a66cbc2 100644 --- a/index.js +++ b/index.js @@ -15,132 +15,9 @@ const postcss = require('postcss') const postcssrc = require('postcss-load-config') const reporter = require('postcss-reporter/lib/formatter')() +const argv = require('./lib/args') const depGraph = require('./lib/depGraph') -const logo = ` - /|\\ - // // - // // - //___*___*___// - //--*---------*--// - /|| * * ||/ - // ||* *|| // - // || * * || // - //_____||___*_________*___||_____// -` - -const version = () => { - const cli = require('./package.json').version - - return chalk.bold.red(` - /|\\ - // // - // // - //___*___*___// - //--*---------*--// - /|| * * ||/ - // ||* v${cli} *|| // - // || * * || // - //_____||___*_________*___||_____// - `) -} - -const argv = require('yargs') - .usage( - `${chalk.bold.red(logo)} -Usage: - - $0 [input.css] [OPTIONS] [--output|-o output.css] [--watch]` - ) - .option('o', { - alias: 'output', - desc: 'Output file', - type: 'string' - }) - .option('d', { - alias: 'dir', - desc: 'Output directory', - type: 'string' - }) - .option('r', { - alias: 'replace', - desc: 'Replace (overwrite) the input file', - type: 'boolean' - }) - .option('u', { - alias: 'use', - desc: 'List of postcss plugins to use', - type: 'array' - }) - .option('p', { - alias: 'parser', - desc: 'Custom postcss parser', - type: 'string' - }) - .option('t', { - alias: 'stringifier', - desc: 'Custom postcss stringifier', - type: 'string' - }) - .option('s', { - alias: 'syntax', - desc: 'Custom postcss syntax', - type: 'string' - }) - .option('w', { - alias: 'watch', - desc: 'Watch files for changes and recompile as needed', - type: 'boolean' - }) - .option('poll', { - desc: - 'Use polling for file watching. Can optionally pass polling interval; default 100 ms' - }) - .option('x', { - alias: 'ext', - desc: 'Override the output file extension', - type: 'string', - coerce(ext) { - if (ext.indexOf('.') !== 0) return `.${ext}` - return ext - } - }) - .option('e', { - alias: 'env', - desc: 'A shortcut for setting NODE_ENV', - type: 'string' - }) - .option('b', { - alias: 'base', - desc: - 'Mirror the directory structure relative to this path in the output directory, this only works together with --dir', - type: 'string' - }) - .option('c', { - alias: 'config', - desc: 'Set a custom path to look for a config file', - type: 'string' - }) - .alias('m', 'map') - .describe('m', 'Create an external sourcemap') - .describe('no-map', 'Disable the default inline sourcemaps') - .version(version) - .alias('v', 'version') - .help('h') - .alias('h', 'help') - .example('$0 input.css -o output.css', 'Basic usage') - .example( - 'cat input.css | $0 -u autoprefixer > output.css', - 'Piping input & output' - ) - .epilog( - `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. - -If there are multiple input files, the --dir or --replace option must be passed. - -For more details, please see https://github.com/postcss/postcss-cli` - ).argv - const dir = argv.dir let input = argv._ diff --git a/lib/args.js b/lib/args.js new file mode 100644 index 0000000..e585b30 --- /dev/null +++ b/lib/args.js @@ -0,0 +1,126 @@ +'use strict' +const chalk = require('chalk') + +const logo = ` + /|\\ + // // + // // + //___*___*___// + //--*---------*--// + /|| * * ||/ + // ||* *|| // + // || * * || // + //_____||___*_________*___||_____// +` + +const version = () => { + const cli = require('../package.json').version + + return chalk.bold.red(` + /|\\ + // // + // // + //___*___*___// + //--*---------*--// + /|| * * ||/ + // ||* v${cli} *|| // + // || * * || // + //_____||___*_________*___||_____// + `) +} + +module.exports = require('yargs') + .usage( + `${chalk.bold.red(logo)} +Usage: + + $0 [input.css] [OPTIONS] [--output|-o output.css] [--watch]` + ) + .option('o', { + alias: 'output', + desc: 'Output file', + type: 'string' + }) + .option('d', { + alias: 'dir', + desc: 'Output directory', + type: 'string' + }) + .option('r', { + alias: 'replace', + desc: 'Replace (overwrite) the input file', + type: 'boolean' + }) + .option('u', { + alias: 'use', + desc: 'List of postcss plugins to use', + type: 'array' + }) + .option('p', { + alias: 'parser', + desc: 'Custom postcss parser', + type: 'string' + }) + .option('t', { + alias: 'stringifier', + desc: 'Custom postcss stringifier', + type: 'string' + }) + .option('s', { + alias: 'syntax', + desc: 'Custom postcss syntax', + type: 'string' + }) + .option('w', { + alias: 'watch', + desc: 'Watch files for changes and recompile as needed', + type: 'boolean' + }) + .option('poll', { + desc: + 'Use polling for file watching. Can optionally pass polling interval; default 100 ms' + }) + .option('x', { + alias: 'ext', + desc: 'Override the output file extension', + type: 'string', + coerce(ext) { + if (ext.indexOf('.') !== 0) return `.${ext}` + return ext + } + }) + .option('e', { + alias: 'env', + desc: 'A shortcut for setting NODE_ENV', + type: 'string' + }) + .option('b', { + alias: 'base', + desc: + 'Mirror the directory structure relative to this path in the output directory, this only works together with --dir', + type: 'string' + }) + .option('c', { + alias: 'config', + desc: 'Set a custom path to look for a config file', + type: 'string' + }) + .alias('m', 'map') + .describe('m', 'Create an external sourcemap') + .describe('no-map', 'Disable the default inline sourcemaps') + .version(version) + .alias('v', 'version') + .help('h') + .alias('h', 'help') + .example('$0 input.css -o output.css', 'Basic usage') + .example( + 'cat input.css | $0 -u autoprefixer > output.css', + 'Piping input & output' + ) + .epilog( + `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. + +If there are multiple input files, the --dir or --replace option must be passed. + +For more details, please see https://github.com/postcss/postcss-cli` + ).argv From 84552206a656c508f8cc53afce138ba7cdb25f2a Mon Sep 17 00:00:00 2001 From: RyanZim Date: Thu, 17 Aug 2017 19:01:24 -0400 Subject: [PATCH 013/251] Prevent cosmiconfig from reading from process.argv Fixes #148 --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a66cbc2..a7c400a 100644 --- a/index.js +++ b/index.js @@ -119,7 +119,9 @@ Promise.resolve() function rc(ctx, path) { if (argv.use) return Promise.resolve() - return postcssrc(ctx, path) + // Set argv: false to keep cosmiconfig from attempting to read the --config + // flag from process.argv + return postcssrc(ctx, path, { argv: false }) .then(rc => { if (rc.options.from || rc.options.to) { error( From 6f4ca1d9867f7239d6f19eff67071e29e151e827 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Thu, 17 Aug 2017 19:24:46 -0400 Subject: [PATCH 014/251] Update dependencies and ava devDep --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1b78248..9c95fd1 100644 --- a/package.json +++ b/package.json @@ -17,22 +17,22 @@ "test": "nyc ava -v" }, "dependencies": { - "chalk": "^1.1.3", + "chalk": "^2.1.0", "chokidar": "^1.6.1", "dependency-graph": "^0.5.0", - "fs-extra": "^3.0.1", + "fs-extra": "^4.0.1", "get-stdin": "^5.0.1", "globby": "^6.1.0", "ora": "^1.1.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", - "postcss-reporter": "^4.0.0", + "postcss-reporter": "^5.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "yargs": "^8.0.1" }, "devDependencies": { - "ava": "^0.19.1", + "ava": "^0.22.0", "coveralls": "^2.12.0", "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", From 37bf3d12f0ae5d4e3a21aef6a304c0b0538ea759 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Thu, 17 Aug 2017 19:41:02 -0400 Subject: [PATCH 015/251] 4.1.1 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cbaecd..a59b572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +4.1.1 / 2017-08-17 +================== + +- Fixed bug with `--config` +- Upgraded dependencies + 4.1.0 / 2017-06-10 ================== From 0ac612c5cf144e415e52e358661057347acbb2cf Mon Sep 17 00:00:00 2001 From: RyanZim Date: Thu, 17 Aug 2017 19:41:11 -0400 Subject: [PATCH 016/251] 4.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c95fd1..c4c1189 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "4.1.0", + "version": "4.1.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 28fa45a8ed2e80198d6c1aca8d9be49717e702b9 Mon Sep 17 00:00:00 2001 From: Danny Andrews Date: Thu, 24 Aug 2017 17:56:26 -0500 Subject: [PATCH 017/251] Update docs to quote glob options (#154) Fixes #142. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e5c5f9..625d168 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,13 @@ postcss [input.css] [OPTIONS] [-o|--output output.css] [-w|--watch] The input may also be a glob: ```bash -postcss src/*.css [OPTIONS] +postcss "src/*.css" [OPTIONS] ``` Recursively read a directory: ```bash -postcss src/**/*.css [OPTIONS] +postcss "src/**/*.css" [OPTIONS] ``` > ⚠️ If there are multiple input files, the --dir or --replace option must be passed. From e2630606ae0b622a4d56cadafb4febe7fb11b2da Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 21 Oct 2017 11:06:20 -0400 Subject: [PATCH 018/251] Fix prettier build, pin prettier version --- index.js | 64 ++++++++++++++++++++++++++------------------------- package.json | 2 +- test/watch.js | 12 +++++++--- 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/index.js b/index.js index a7c400a..50825f9 100644 --- a/index.js +++ b/index.js @@ -204,43 +204,45 @@ function css(css, file) { ) } - return postcss(config.plugins).process(css, options).then(result => { - const tasks = [] - - if (options.to) { - tasks.push(fs.outputFile(options.to, result.css)) - - if (result.map) { - tasks.push( - fs.outputFile( - options.to.replace( - path.extname(options.to), - `${path.extname(options.to)}.map` - ), - result.map + return postcss(config.plugins) + .process(css, options) + .then(result => { + const tasks = [] + + if (options.to) { + tasks.push(fs.outputFile(options.to, result.css)) + + if (result.map) { + tasks.push( + fs.outputFile( + options.to.replace( + path.extname(options.to), + `${path.extname(options.to)}.map` + ), + result.map + ) ) + } + } else { + spinner.text = chalk.bold.green( + `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` ) + spinner.succeed() + return process.stdout.write(result.css, 'utf8') } - } else { - spinner.text = chalk.bold.green( - `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` - ) - spinner.succeed() - return process.stdout.write(result.css, 'utf8') - } - return Promise.all(tasks).then(() => { - spinner.text = chalk.bold.green( - `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` - ) - if (result.warnings().length) { - spinner.fail() - console.warn(reporter(result)) - } else spinner.succeed() + return Promise.all(tasks).then(() => { + spinner.text = chalk.bold.green( + `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` + ) + if (result.warnings().length) { + spinner.fail() + console.warn(reporter(result)) + } else spinner.succeed() - return result + return result + }) }) - }) }) .catch(err => { spinner.fail() diff --git a/package.json b/package.json index c4c1189..a4b3305 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^10.0.0", - "prettier": "^1.5.3", + "prettier": "1.7.4", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" diff --git a/test/watch.js b/test/watch.js index 2ac43fd..8afd092 100644 --- a/test/watch.js +++ b/test/watch.js @@ -36,7 +36,9 @@ test.cb('--watch works', t => { // When the change is picked up: watcher.on('change', p => { if (p === 'output.css') { - isEqual(p, 'test/fixtures/b.css').then(() => done()).catch(done) + isEqual(p, 'test/fixtures/b.css') + .then(() => done()) + .catch(done) } }) @@ -113,7 +115,9 @@ test.cb('--watch postcss.config.js', t => { // When the change is picked up: watcher.on('change', p => { if (p === 'output.css') { - isEqual(p, 'test/fixtures/a.css').then(() => done()).catch(done) + isEqual(p, 'test/fixtures/a.css') + .then(() => done()) + .catch(done) } }) @@ -181,7 +185,9 @@ test.cb('--watch dependencies', t => { // When the change is picked up: watcher.on('change', p => { if (p === 'output.css') { - isEqual(p, 'test/fixtures/b.css').then(() => done()).catch(done) + isEqual(p, 'test/fixtures/b.css') + .then(() => done()) + .catch(done) } }) From 11ced728c412b54bc85036984be4b4bef0d711ec Mon Sep 17 00:00:00 2001 From: RyanZim Date: Tue, 24 Oct 2017 19:41:56 -0400 Subject: [PATCH 019/251] Upgrade yargs to v10.0.3 --- lib/args.js | 10 +++------- package.json | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/args.js b/lib/args.js index e585b30..ccf9c40 100644 --- a/lib/args.js +++ b/lib/args.js @@ -13,10 +13,8 @@ const logo = ` //_____||___*_________*___||_____// ` -const version = () => { - const cli = require('../package.json').version - - return chalk.bold.red(` +const cli = require('../package.json').version +const version = chalk.bold.red(` /|\\ // // // // @@ -26,8 +24,7 @@ const version = () => { // ||* v${cli} *|| // // || * * || // //_____||___*_________*___||_____// - `) -} +`) module.exports = require('yargs') .usage( @@ -110,7 +107,6 @@ Usage: .describe('no-map', 'Disable the default inline sourcemaps') .version(version) .alias('v', 'version') - .help('h') .alias('h', 'help') .example('$0 input.css -o output.css', 'Basic usage') .example( diff --git a/package.json b/package.json index a4b3305..011e064 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "postcss-reporter": "^5.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "yargs": "^8.0.1" + "yargs": "^10.0.3" }, "devDependencies": { "ava": "^0.22.0", From ec7cec0773d41a40d88cebcde25e7abbe7a1129b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 21 Oct 2017 23:31:13 +0000 Subject: [PATCH 020/251] Update dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 011e064..a7d7afc 100644 --- a/package.json +++ b/package.json @@ -33,13 +33,13 @@ }, "devDependencies": { "ava": "^0.22.0", - "coveralls": "^2.12.0", + "coveralls": "^3.0.0", "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", "eslint-plugin-prettier": "^2.1.2", "nyc": "^11.0.2", "per-env": "^1.0.2", - "postcss-import": "^10.0.0", + "postcss-import": "^11.0.0", "prettier": "1.7.4", "standard": "^10.0.2", "sugarss": "^1.0.0", From 43b604d64c6b3f026d8f3d7d2f1e8e81d4ec08f9 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 21 Oct 2017 23:31:48 +0000 Subject: [PATCH 021/251] Add Greenkeeper badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 625d168..58887c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] +[![Greenkeeper badge](https://badges.greenkeeper.io/postcss/postcss-cli.svg)](https://greenkeeper.io/) [![tests][tests]][tests-url] [![cover][cover]][cover-url] [![code style][style]][style-url] From 1a9060f146f743fce73a7f8b40e8380432c75894 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Wed, 25 Oct 2017 10:13:00 -0400 Subject: [PATCH 022/251] Skip watch tests for now; they're too flaky on the CI --- test/watch.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/watch.js b/test/watch.js index 8afd092..24385a0 100644 --- a/test/watch.js +++ b/test/watch.js @@ -8,7 +8,9 @@ import chokidar from 'chokidar' import ENV from './helpers/env.js' import read from './helpers/read.js' -test.cb('--watch works', t => { +// XXX: All the tests in these files are skipped; the tests are too flaky on the CI + +test.cb.skip('--watch works', t => { let cp t.plan(2) @@ -77,7 +79,7 @@ test.cb('--watch works', t => { setTimeout(() => t.end('test timeout'), 50000) }) -test.cb('--watch postcss.config.js', t => { +test.cb.skip('--watch postcss.config.js', t => { let cp t.plan(2) @@ -157,7 +159,7 @@ test.cb('--watch postcss.config.js', t => { setTimeout(() => t.end('test timeout'), 50000) }) -test.cb('--watch dependencies', t => { +test.cb.skip('--watch dependencies', t => { let cp t.plan(2) @@ -234,7 +236,7 @@ test.cb('--watch dependencies', t => { setTimeout(() => t.end('test timeout'), 50000) }) -test.cb("--watch doesn't exit on CssSyntaxError", t => { +test.cb.skip("--watch doesn't exit on CssSyntaxError", t => { t.plan(0) ENV('', ['a.css']) From de0c81f784ab6093fd14dc100c1673ae0998c199 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Wed, 25 Oct 2017 10:17:38 -0400 Subject: [PATCH 023/251] Remove standard badge --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 58887c7..ae30a6f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Greenkeeper badge](https://badges.greenkeeper.io/postcss/postcss-cli.svg)](https://greenkeeper.io/) [![tests][tests]][tests-url] [![cover][cover]][cover-url] -[![code style][style]][style-url] [![chat][chat]][chat-url]
@@ -144,9 +143,6 @@ module.exports = (ctx) => ({ [tests]: http://img.shields.io/travis/postcss/postcss-cli/master.svg [tests-url]: https://travis-ci.org/postcss/postcss-cli -[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg -[style-url]: http://standardjs.com/ - [cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg [cover-url]: https://coveralls.io/github/postcss/postcss-cli From c3131b6d669f81f201130174683a063152e7507e Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 7 Nov 2017 12:59:11 +0000 Subject: [PATCH 024/251] Update prettier to version 1.8.1 Closes #171 --- package.json | 2 +- test/error.js | 35 +++++++++++++++-------------------- test/watch.js | 21 +++++++++------------ 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index a7d7afc..dc70ec0 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.7.4", + "prettier": "1.8.1", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" diff --git a/test/error.js b/test/error.js index 1d1a097..654b785 100644 --- a/test/error.js +++ b/test/error.js @@ -41,27 +41,22 @@ test.failing('invalid --config', t => { }) test('PluginError', t => { - return cli([ - 'test/fixtures/a.css', - '-u', - 'postcss-plugin', - '-o', - tmp() - ]).then(({ err, code }) => { - t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /Plugin Error: Cannot find module 'postcss-plugin'/) - }) + return cli(['test/fixtures/a.css', '-u', 'postcss-plugin', '-o', tmp()]).then( + ({ err, code }) => { + t.is(code, 1, 'expected non-zero error code') + t.regex( + err.toString(), + /Plugin Error: Cannot find module 'postcss-plugin'/ + ) + } + ) }) test('CssSyntaxError', t => { - return cli([ - 'test/fixtures/a.css', - '-p', - 'sugarss', - '-o', - tmp() - ]).then(({ err, code }) => { - t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /\[1:4] Unnecessary curly bracket/) - }) + return cli(['test/fixtures/a.css', '-p', 'sugarss', '-o', tmp()]).then( + ({ err, code }) => { + t.is(code, 1, 'expected non-zero error code') + t.regex(err.toString(), /\[1:4] Unnecessary curly bracket/) + } + ) }) diff --git a/test/watch.js b/test/watch.js index 24385a0..b13d532 100644 --- a/test/watch.js +++ b/test/watch.js @@ -59,10 +59,9 @@ test.cb.skip('--watch works', t => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected) - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { @@ -139,10 +138,9 @@ test.cb.skip('--watch postcss.config.js', t => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected) - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { @@ -217,10 +215,9 @@ test.cb.skip('--watch dependencies', t => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected) - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { From 85daee9fcd8b5f7472e5866a31c26d98481192b8 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 9 Nov 2017 10:04:42 -0500 Subject: [PATCH 025/251] Update prettier to version 1.8.2 (#172) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc70ec0..2b79675 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.8.1", + "prettier": "1.8.2", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" From b4d5d3d79f6249dcbb3593137c93a82e497c1049 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 27 Nov 2017 15:05:42 -0500 Subject: [PATCH 026/251] Update ava to version 0.24.0 (#174) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b79675..17b4622 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "yargs": "^10.0.3" }, "devDependencies": { - "ava": "^0.22.0", + "ava": "^0.24.0", "coveralls": "^3.0.0", "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", From 61349474ba9e9d16ac3752d9cc80959f391749d2 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 5 Dec 2017 08:52:49 -0500 Subject: [PATCH 027/251] Update prettier to version 1.9.0 (#179) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17b4622..441793d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.8.2", + "prettier": "1.9.0", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" From 077364fb81ce5add451bb91ff27e7d0969c720ce Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 17 Jan 2018 12:49:54 -0500 Subject: [PATCH 028/251] Update dependency-graph to version 0.7.0 (#189) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 441793d..4777418 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "chalk": "^2.1.0", "chokidar": "^1.6.1", - "dependency-graph": "^0.5.0", + "dependency-graph": "^0.7.0", "fs-extra": "^4.0.1", "get-stdin": "^5.0.1", "globby": "^6.1.0", From c8544adcee7b612baac9a94818e805373ff0f5b3 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 23 Jan 2018 16:19:26 -0500 Subject: [PATCH 029/251] Update yargs to version 11.0.0 (#192) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4777418..7adaeac 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "postcss-reporter": "^5.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "yargs": "^10.0.3" + "yargs": "^11.0.0" }, "devDependencies": { "ava": "^0.24.0", From 49bb585c0c87c5f84641f16d02b0852e52520d7a Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 26 Jan 2018 09:57:28 -0500 Subject: [PATCH 030/251] Update ava to version 0.25.0 (#193) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7adaeac..828b78d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "yargs": "^11.0.0" }, "devDependencies": { - "ava": "^0.24.0", + "ava": "^0.25.0", "coveralls": "^3.0.0", "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", From f94496f95bc45c274a102239d159651471d757ac Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 2 Feb 2018 02:24:21 +0000 Subject: [PATCH 031/251] Pin ora to 1.3.0 to fix tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 828b78d..b65d651 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "fs-extra": "^4.0.1", "get-stdin": "^5.0.1", "globby": "^6.1.0", - "ora": "^1.1.0", + "ora": "1.3.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", "postcss-reporter": "^5.0.0", From 596b1f45e44c20002db8250ebd82b5bcda53fffa Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 5 Dec 2017 18:59:41 -0500 Subject: [PATCH 032/251] Update prettier to version 1.9.1 (#180) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b65d651..caaa682 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.9.0", + "prettier": "1.9.1", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" From f0af2e411ee4791506e8f6697480f2dd823e7287 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 5 Dec 2017 16:01:01 -0800 Subject: [PATCH 033/251] postcss should exit with code 1 when there's an error; even with --watch (#178) --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 50825f9..44e444c 100644 --- a/index.js +++ b/index.js @@ -114,7 +114,11 @@ Promise.resolve() }) } }) - .catch(error) + .catch(err => { + error(err) + + process.exit(1) + }) function rc(ctx, path) { if (argv.use) return Promise.resolve() From cc3f696b1be3cf90ee59eea25ca999b601b0ed9a Mon Sep 17 00:00:00 2001 From: RyanZim Date: Tue, 5 Dec 2017 20:22:10 -0500 Subject: [PATCH 034/251] BREAKING: Revamp args parsing - Remove extra aliases -x, -p, -s, -t, -e, -b, & -c - Better usage text - Split opts into groups in the --help message - Way stricter opts parsing to prevent stupid combinations of options Fixes #166; Fixes #126 --- README.md | 84 ++++++++++++++++++++++--------------------- lib/args.js | 87 ++++++++++++++++++++++++++------------------- test/error.js | 2 +- test/parser.js | 2 +- test/stdout.js | 2 +- test/stringifier.js | 2 +- test/syntax.js | 2 +- 7 files changed, 98 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index ae30a6f..7f9dbf1 100644 --- a/README.md +++ b/README.md @@ -22,56 +22,58 @@ npm i -g|-D postcss-cli

Usage

-```bash -postcss [input.css] [OPTIONS] [-o|--output output.css] [-w|--watch] ``` +Usage: + postcss [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] + postcss ... [OPTIONS] --dir [--watch|-w] + postcss ... [OPTIONS] --replace + +Basic options: + -o, --output Output file [string] + -d, --dir Output directory [string] + -r, --replace Replace (overwrite) the input file [boolean] + --map, -m Create an external sourcemap + --no-map Disable the default inline sourcemaps + --watch, -w Watch files for changes and recompile as needed [boolean] + --env A shortcut for setting NODE_ENV [string] + +Options for when not using a config file: + -u, --use List of postcss plugins to use [array] + --parser Custom postcss parser [string] + --stringifier Custom postcss stringifier [string] + --syntax Custom postcss syntax [string] + +Advanced options: + --ext Override the output file extension; for use with --dir [string] + --base Mirror the directory structure relative to this path in the output + directory, for use with --dir [string] + --poll Use polling for file watching. Can optionally pass polling interval; + default 100 ms + --config Set a custom path to look for a config file [string] + +Options: + -v, --version Show version number [boolean] + -h, --help Show help [boolean] + +Examples: + postcss input.css -o output.css Basic usage + cat input.css | postcss -u autoprefixer > output.css Piping input & output + +If no input files are passed, it reads from stdin. If neither -o, --dir, or +--replace is passed, it writes to stdout. -The input may also be a glob: - -```bash -postcss "src/*.css" [OPTIONS] +If there are multiple input files, the --dir or --replace option must be passed. +Input files may contain globs. ``` -Recursively read a directory: - -```bash -postcss "src/**/*.css" [OPTIONS] -``` +> ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). -> ⚠️ If there are multiple input files, the --dir or --replace option must be passed. +To recursively read a directory, you'd do: ```bash -cat input.css | postcss [OPTIONS] > output.css +postcss "src/**/*.css" [OPTIONS] ``` -> ⚠️ If no input files are passed, it reads from stdin. If neither -o, --dir, or ---replace is passed, it writes to stdout. - -

Options

- -|Name|Type|Default|Description| -|:---|:--:|:-----:|:----------| -|`-d, --dir`|`{String}`|`undefined`|Output Directory| -|`-b, --base`|`{String}`|`undefined`|Use together with `--dir` for keeping directory structure.| -|`-x, --ext`|`{String}`|`extname(output)`|Output File Extension| -|`-o, --output`|`{String}`|`undefined`|Output File| -|`-r, --replace`|`{String}`|`undefined`|Replace Input <=> Output| -|`-p, --parser`|`{String}`|`undefined`|Custom PostCSS Parser| -|`-s, --syntax`|`{String}`|`undefined`|Custom PostCSS Syntax| -|`-t, --stringifier`|`{String}`|`undefined`|Custom PostCSS Stringifier| -|`-w, --watch`|`{Boolean}`|`false`|Enable Watch Mode| -|`--poll`|`{Boolean\|Number}`|`100`|Use polling for file watching. Can optionally pass polling interval; default 100 ms| -|`-u, --use`|`{Array}`|`[]`|PostCSS Plugins| -|`-m, --map`|`{Boolean}`|`{ inline: true }`|External Sourcemaps| -|`--no-map`|`{Boolean}`|`false`|Disable Sourcemaps| -|`-e, --env`|`{String}`|`process.env.NODE_ENV`|Sets `$NODE_ENV`| -|`-c, --config`|`{String}`|`dirname(file)`|PostCSS Config Path `postcss.config.js`| -|`-h, --help`|`{Boolean}`|`false`|CLI Help| -|`-v, --version`|`{Boolean}`|`false`|CLI Version| - - -> ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). - ### [Config](https://github.com/michael-ciniawsky/postcss-load-config) If you need to pass options to your plugins, or have a long plugin chain, you'll want to use a configuration file. diff --git a/lib/args.js b/lib/args.js index ccf9c40..735c67f 100644 --- a/lib/args.js +++ b/lib/args.js @@ -30,81 +30,94 @@ module.exports = require('yargs') .usage( `${chalk.bold.red(logo)} Usage: - - $0 [input.css] [OPTIONS] [--output|-o output.css] [--watch]` + $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] + $0 ... [OPTIONS] --dir [--watch|-w] + $0 ... [OPTIONS] --replace` ) + .group(['o', 'd', 'r', 'map', 'no-map', 'watch', 'env'], 'Basic options:') .option('o', { alias: 'output', desc: 'Output file', - type: 'string' + type: 'string', + conflicts: ['dir', 'replace'] }) .option('d', { alias: 'dir', desc: 'Output directory', - type: 'string' + type: 'string', + conflicts: ['output', 'replace'] }) .option('r', { alias: 'replace', desc: 'Replace (overwrite) the input file', - type: 'boolean' + type: 'boolean', + // HACK: conflicts doesn't work with boolean opts correctly, so we do this + // See https://github.com/yargs/yargs/issues/929 + coerce: v => v || undefined, + conflicts: ['output', 'dir'] + }) + .alias('map', 'm') + .describe('map', 'Create an external sourcemap') + .describe('no-map', 'Disable the default inline sourcemaps') + .option('watch', { + alias: 'w', + desc: 'Watch files for changes and recompile as needed', + type: 'boolean', + // HACK: conflicts doesn't work with boolean opts correctly, so we do this + // See https://github.com/yargs/yargs/issues/929 + coerce: v => v || undefined, + conflicts: 'replace' + }) + .option('env', { + desc: 'A shortcut for setting NODE_ENV', + type: 'string' }) + .group( + ['u', 'parser', 'stringifier', 'syntax'], + 'Options for when not using a config file:' + ) .option('u', { alias: 'use', desc: 'List of postcss plugins to use', type: 'array' }) - .option('p', { - alias: 'parser', + .option('parser', { desc: 'Custom postcss parser', type: 'string' }) - .option('t', { - alias: 'stringifier', + .option('stringifier', { desc: 'Custom postcss stringifier', type: 'string' }) - .option('s', { - alias: 'syntax', + .option('syntax', { desc: 'Custom postcss syntax', type: 'string' }) - .option('w', { - alias: 'watch', - desc: 'Watch files for changes and recompile as needed', - type: 'boolean' - }) - .option('poll', { - desc: - 'Use polling for file watching. Can optionally pass polling interval; default 100 ms' - }) - .option('x', { - alias: 'ext', - desc: 'Override the output file extension', + .group(['ext', 'base', 'poll', 'config'], 'Advanced options:') + .option('ext', { + desc: 'Override the output file extension; for use with --dir', type: 'string', + implies: 'dir', coerce(ext) { if (ext.indexOf('.') !== 0) return `.${ext}` return ext } }) - .option('e', { - alias: 'env', - desc: 'A shortcut for setting NODE_ENV', - type: 'string' + .option('base', { + desc: + 'Mirror the directory structure relative to this path in the output directory, for use with --dir', + type: 'string', + implies: 'dir' }) - .option('b', { - alias: 'base', + .option('poll', { desc: - 'Mirror the directory structure relative to this path in the output directory, this only works together with --dir', - type: 'string' + 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', + implies: 'watch' }) - .option('c', { - alias: 'config', + .option('config', { desc: 'Set a custom path to look for a config file', type: 'string' }) - .alias('m', 'map') - .describe('m', 'Create an external sourcemap') - .describe('no-map', 'Disable the default inline sourcemaps') .version(version) .alias('v', 'version') .alias('h', 'help') @@ -116,7 +129,7 @@ Usage: .epilog( `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. -If there are multiple input files, the --dir or --replace option must be passed. +If there are multiple input files, the --dir or --replace option must be passed. Input files may contain globs. For more details, please see https://github.com/postcss/postcss-cli` ).argv diff --git a/test/error.js b/test/error.js index 654b785..2820c62 100644 --- a/test/error.js +++ b/test/error.js @@ -53,7 +53,7 @@ test('PluginError', t => { }) test('CssSyntaxError', t => { - return cli(['test/fixtures/a.css', '-p', 'sugarss', '-o', tmp()]).then( + return cli(['test/fixtures/a.css', '--parser', 'sugarss', '-o', tmp()]).then( ({ err, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(err.toString(), /\[1:4] Unnecessary curly bracket/) diff --git a/test/parser.js b/test/parser.js index 46211dc..0febe22 100644 --- a/test/parser.js +++ b/test/parser.js @@ -9,7 +9,7 @@ test('--parser works', async t => { const { error, stderr } = await cli([ 'test/fixtures/a.sss', - '-p', + '--parser', 'sugarss', '-o', output, diff --git a/test/stdout.js b/test/stdout.js index 5033911..388968a 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -9,7 +9,7 @@ import read from './helpers/read.js' test.cb('writes to stdout', t => { const cp = execFile( path.resolve('bin/postcss'), - ['-p', 'sugarss', '-u', 'postcss-import', '--no-map'], + ['--parser', 'sugarss', '-u', 'postcss-import', '--no-map'], (error, stdout, stderr) => { if (error) t.end(error, stderr) diff --git a/test/stringifier.js b/test/stringifier.js index 0eb0d74..4d7f8f8 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -9,7 +9,7 @@ test('--stringifier works', async t => { const { error, stderr } = await cli([ 'test/fixtures/a.css', - '-t', + '--stringifier', 'sugarss', '-o', output, diff --git a/test/syntax.js b/test/syntax.js index 78a496d..39877d8 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -9,7 +9,7 @@ test('--syntax works', async t => { const { error, stderr } = await cli([ 'test/fixtures/a.sss', - '-s', + '--syntax', 'sugarss', '-o', output, From 4b2421b9a57acecd9b64ee0215e3fc558d0ad2bf Mon Sep 17 00:00:00 2001 From: RyanZim Date: Tue, 5 Dec 2017 20:32:01 -0500 Subject: [PATCH 035/251] User-friendly error message when --watch and writing to STDOUT Fixes #156 --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 44e444c..1253481 100644 --- a/index.js +++ b/index.js @@ -50,6 +50,9 @@ if (argv.config) argv.config = path.resolve(argv.config) Promise.resolve() .then(() => { + if (argv.watch && !(argv.output || argv.replace || argv.dir)) { + error('Cannot write to stdout in watch mode') + } if (input && input.length) return globber(input) if (argv.replace || argv.dir) { From fecf8322e16a9399c5aa04b7b0556890b715777d Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 23 Dec 2017 12:30:36 -0500 Subject: [PATCH 036/251] BREAKING: Update globby to version 7.1.1; expand directories Resolve #181 --- README.md | 11 ++++------- lib/args.js | 5 ++++- package.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7f9dbf1..f09fd1e 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ npm i -g|-D postcss-cli Usage: postcss [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] postcss ... [OPTIONS] --dir [--watch|-w] + postcss [OPTIONS] --dir [--watch|-w] postcss ... [OPTIONS] --replace Basic options: @@ -63,17 +64,13 @@ If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. If there are multiple input files, the --dir or --replace option must be passed. -Input files may contain globs. + +Input files may contain globs. If you pass an input directory, it will process +all files in the directory and any subdirectories. ``` > ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). -To recursively read a directory, you'd do: - -```bash -postcss "src/**/*.css" [OPTIONS] -``` - ### [Config](https://github.com/michael-ciniawsky/postcss-load-config) If you need to pass options to your plugins, or have a long plugin chain, you'll want to use a configuration file. diff --git a/lib/args.js b/lib/args.js index 735c67f..b07b826 100644 --- a/lib/args.js +++ b/lib/args.js @@ -32,6 +32,7 @@ module.exports = require('yargs') Usage: $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] $0 ... [OPTIONS] --dir [--watch|-w] + $0 [OPTIONS] --dir [--watch|-w] $0 ... [OPTIONS] --replace` ) .group(['o', 'd', 'r', 'map', 'no-map', 'watch', 'env'], 'Basic options:') @@ -129,7 +130,9 @@ Usage: .epilog( `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. -If there are multiple input files, the --dir or --replace option must be passed. Input files may contain globs. +If there are multiple input files, the --dir or --replace option must be passed. + +Input files may contain globs. If you pass an input directory, it will process all files in the directory and any subdirectories. For more details, please see https://github.com/postcss/postcss-cli` ).argv diff --git a/package.json b/package.json index caaa682..fe40ed7 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependency-graph": "^0.7.0", "fs-extra": "^4.0.1", "get-stdin": "^5.0.1", - "globby": "^6.1.0", + "globby": "^7.1.1", "ora": "1.3.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", From 1fa3574f20d752ef28345a94912a87f9349f3cd3 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 23 Dec 2017 12:41:58 -0500 Subject: [PATCH 037/251] Update prettier to version 1.9.2 (#184) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe40ed7..2814aba 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.9.1", + "prettier": "1.9.2", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" From 72557a937fd50f420e59705f02213332aa43e058 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 23 Dec 2017 12:43:06 -0500 Subject: [PATCH 038/251] Update fs-extra to version 5.0.0 (#183) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2814aba..98b0894 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "chalk": "^2.1.0", "chokidar": "^1.6.1", "dependency-graph": "^0.7.0", - "fs-extra": "^4.0.1", + "fs-extra": "^5.0.0", "get-stdin": "^5.0.1", "globby": "^7.1.1", "ora": "1.3.0", From f16d0d4b5422071742417b133c3bf1ada728f6a7 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 23 Dec 2017 12:52:29 -0500 Subject: [PATCH 039/251] BREAKING: Don't exit watch mode when a plugin errors Fixes #127 --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1253481..74baace 100644 --- a/index.js +++ b/index.js @@ -293,10 +293,10 @@ function error(err) { console.error('\n', chalk.bold.red(`[${err.message}`)) console.error('\n', err.showSourceCode(), '\n\n') - - if (argv.watch) return } else { console.error(err) } + // Watch mode shouldn't exit on error + if (argv.watch) return process.exit(1) } From 06aa6eeb745e09e1ba3cf8d28299b3925dd4c9fe Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 23 Dec 2017 17:50:06 -0500 Subject: [PATCH 040/251] BREAKING: Be silent, add --verbose, change logging format - postcss doesn't output any status logging by default - Added --verbose flag to reenable status logging - Removed ora spinners, simpler logging - Changed wording of a few log messages; also changed colors - Use simpler error message printing --- README.md | 1 + index.js | 94 +++++++++++++++++++-------------------------------- lib/args.js | 9 ++++- package.json | 1 - test/error.js | 5 ++- 5 files changed, 47 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index f09fd1e..1b486b1 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Basic options: -r, --replace Replace (overwrite) the input file [boolean] --map, -m Create an external sourcemap --no-map Disable the default inline sourcemaps + --verbose Be verbose [boolean] --watch, -w Watch files for changes and recompile as needed [boolean] --env A shortcut for setting NODE_ENV [string] diff --git a/index.js b/index.js index 74baace..f21a040 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,6 @@ const fs = require('fs-extra') const path = require('path') -const ora = require('ora') const prettyHrtime = require('pretty-hrtime') const stdin = require('get-stdin') const read = require('read-cache') @@ -25,8 +24,6 @@ const output = argv.output if (argv.map) argv.map = { inline: false } -const spinner = ora() - let config = { options: { map: argv.map !== undefined ? argv.map : { inline: true }, @@ -86,6 +83,8 @@ Promise.resolve() }) .then(results => { if (argv.watch) { + const printMessage = () => + printVerbose(chalk.dim('\nWaiting for file changes...')) const watcher = chokidar.watch(input.concat(dependencies(results)), { usePolling: argv.poll, interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100 @@ -93,28 +92,22 @@ Promise.resolve() if (config.file) watcher.add(config.file) - watcher - .on('ready', () => { - console.warn(chalk.bold.cyan('Waiting for file changes...')) - }) - .on('change', file => { - let recompile = [] + watcher.on('ready', printMessage).on('change', file => { + let recompile = [] - if (~input.indexOf(file)) recompile.push(file) + if (~input.indexOf(file)) recompile.push(file) - recompile = recompile.concat( - depGraph.dependantsOf(file).filter(file => ~input.indexOf(file)) - ) + recompile = recompile.concat( + depGraph.dependantsOf(file).filter(file => ~input.indexOf(file)) + ) - if (!recompile.length) recompile = input + if (!recompile.length) recompile = input - return files(recompile) - .then(results => watcher.add(dependencies(results))) - .then(() => { - console.warn(chalk.bold.cyan('Waiting for file changes...')) - }) - .catch(error) - }) + return files(recompile) + .then(results => watcher.add(dependencies(results))) + .then(printMessage) + .catch(error) + }) } }) .catch(err => { @@ -179,8 +172,7 @@ function css(css, file) { const time = process.hrtime() - spinner.text = `Processing ${relativePath}` - spinner.start() + printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`) return rc(ctx, argv.config) .then(() => { @@ -205,7 +197,6 @@ function css(css, file) { } if (!options.to && config.options.map && !config.options.map.inline) { - spinner.fail() error( 'Output Error: Cannot output external sourcemaps when writing to STDOUT' ) @@ -220,39 +211,29 @@ function css(css, file) { tasks.push(fs.outputFile(options.to, result.css)) if (result.map) { - tasks.push( - fs.outputFile( - options.to.replace( - path.extname(options.to), - `${path.extname(options.to)}.map` - ), - result.map - ) + const mapfile = options.to.replace( + path.extname(options.to), + `${path.extname(options.to)}.map` ) + tasks.push(fs.outputFile(mapfile, result.map)) } - } else { - spinner.text = chalk.bold.green( - `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` - ) - spinner.succeed() - return process.stdout.write(result.css, 'utf8') - } + } else process.stdout.write(result.css, 'utf8') return Promise.all(tasks).then(() => { - spinner.text = chalk.bold.green( - `Finished ${relativePath} (${prettyHrtime(process.hrtime(time))})` + const prettyTime = prettyHrtime(process.hrtime(time)) + printVerbose( + chalk`{green Finished {bold ${relativePath}} in {bold ${prettyTime}}}` ) + if (result.warnings().length) { - spinner.fail() console.warn(reporter(result)) - } else spinner.succeed() + } return result }) }) }) .catch(err => { - spinner.fail() throw err }) } @@ -274,25 +255,18 @@ function dependencies(results) { return messages } +function printVerbose(message) { + if (argv.verbose) console.warn(message) +} + function error(err) { + // Seperate error from logging output + if (argv.verbose) console.error() + if (typeof err === 'string') { - spinner.fail(chalk.bold.red(err)) + console.error(chalk.red(err)) } else if (err.name === 'CssSyntaxError') { - console.error('\n') - - spinner.text = spinner.text.replace('Processing ', '') - spinner.fail(chalk.bold.red(`Syntax Error: ${spinner.text}`)) - - if (err.file) { - err.message = err.message.substr(err.file.length + 1) - } else { - err.message = err.message.replace(':', '') - } - - err.message = err.message.replace(/:\s/, '] ') - - console.error('\n', chalk.bold.red(`[${err.message}`)) - console.error('\n', err.showSourceCode(), '\n\n') + console.error(err.toString()) } else { console.error(err) } diff --git a/lib/args.js b/lib/args.js index b07b826..a251cf7 100644 --- a/lib/args.js +++ b/lib/args.js @@ -35,7 +35,10 @@ Usage: $0 [OPTIONS] --dir [--watch|-w] $0 ... [OPTIONS] --replace` ) - .group(['o', 'd', 'r', 'map', 'no-map', 'watch', 'env'], 'Basic options:') + .group( + ['o', 'd', 'r', 'map', 'no-map', 'verbose', 'watch', 'env'], + 'Basic options:' + ) .option('o', { alias: 'output', desc: 'Output file', @@ -60,6 +63,10 @@ Usage: .alias('map', 'm') .describe('map', 'Create an external sourcemap') .describe('no-map', 'Disable the default inline sourcemaps') + .option('verbose', { + desc: 'Be verbose', + type: 'boolean' + }) .option('watch', { alias: 'w', desc: 'Watch files for changes and recompile as needed', diff --git a/package.json b/package.json index 98b0894..c8f47ec 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "fs-extra": "^5.0.0", "get-stdin": "^5.0.1", "globby": "^7.1.1", - "ora": "1.3.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", "postcss-reporter": "^5.0.0", diff --git a/test/error.js b/test/error.js index 2820c62..b49781b 100644 --- a/test/error.js +++ b/test/error.js @@ -56,7 +56,10 @@ test('CssSyntaxError', t => { return cli(['test/fixtures/a.css', '--parser', 'sugarss', '-o', tmp()]).then( ({ err, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /\[1:4] Unnecessary curly bracket/) + t.regex( + err.toString(), + /CssSyntaxError: .*a.css:1:4: Unnecessary curly bracket/ + ) } ) }) From aa0088d9550a0ded398c2ddb0fce6a9422d178b5 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 23 Dec 2017 17:53:17 -0500 Subject: [PATCH 041/251] BREAKING: Remove -v alias for --version --- README.md | 2 +- lib/args.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b486b1..49b8bf8 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Advanced options: --config Set a custom path to look for a config file [string] Options: - -v, --version Show version number [boolean] + --version Show version number [boolean] -h, --help Show help [boolean] Examples: diff --git a/lib/args.js b/lib/args.js index a251cf7..7a2ca92 100644 --- a/lib/args.js +++ b/lib/args.js @@ -127,7 +127,6 @@ Usage: type: 'string' }) .version(version) - .alias('v', 'version') .alias('h', 'help') .example('$0 input.css -o output.css', 'Basic usage') .example( From 908817a001989f59d025a56f776e5f229f24800f Mon Sep 17 00:00:00 2001 From: RyanZim Date: Sat, 23 Dec 2017 18:06:41 -0500 Subject: [PATCH 042/251] Update CI configs --- .travis.yml | 1 + appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c7f034b..915376c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: false language: node_js node_js: - node + - 8 - 6 - 4 script: diff --git a/appveyor.yml b/appveyor.yml index f454e5d..6450020 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ environment: matrix: - - nodejs_version: "7" + - nodejs_version: "8" - nodejs_version: "6" - nodejs_version: "4" From b570fee2eb81b53769ff3cf4ad0c9ce5f3d96dce Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Sat, 3 Feb 2018 15:15:47 -0500 Subject: [PATCH 043/251] Upgrade chokidar to v2.0.0 Closes #186 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8f47ec..6541366 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "chalk": "^2.1.0", - "chokidar": "^1.6.1", + "chokidar": "^2.0.0", "dependency-graph": "^0.7.0", "fs-extra": "^5.0.0", "get-stdin": "^5.0.1", From 205a83b96264885289413db5cb9b3405e829ab51 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Sat, 3 Feb 2018 15:28:40 -0500 Subject: [PATCH 044/251] Changes to prettier config - Upgrade prettier - Use directly instead of via eslint plugin - Format .md as well as .js --- .eslintrc.yaml | 5 - .prettierignore | 1 + CHANGELOG.md | 284 ++++++++++++++++++++++-------------------------- README.md | 34 +++--- package.json | 8 +- 5 files changed, 147 insertions(+), 185 deletions(-) create mode 100644 .prettierignore diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ae169c8..0473b0f 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,10 +1,5 @@ env: node: true extends: problems -plugins: - - prettier rules: - prettier/prettier: - - error - - { semi: false, singleQuote: true } no-console: off diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..3018b3a --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +.tmp/ diff --git a/CHANGELOG.md b/CHANGELOG.md index a59b572..dd27f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,245 +1,215 @@ -4.1.1 / 2017-08-17 -================== +# 4.1.1 / 2017-08-17 -- Fixed bug with `--config` -- Upgraded dependencies +* Fixed bug with `--config` +* Upgraded dependencies -4.1.0 / 2017-06-10 -================== +# 4.1.0 / 2017-06-10 -- Can now pass a number to `--poll` to set poll interval -- Updated `postcss-reporter` dependency to v4.0.0 +* Can now pass a number to `--poll` to set poll interval +* Updated `postcss-reporter` dependency to v4.0.0 -4.0.0 / 2017-05-09 -================== +# 4.0.0 / 2017-05-09 -- **BREAKING:** Upgrade postcss to v6.x +* **BREAKING:** Upgrade postcss to v6.x -3.2.0 / 2017-04-21 -================== +# 3.2.0 / 2017-04-21 -- Added `--base` CLI option for keeping directory structure +* Added `--base` CLI option for keeping directory structure -3.1.1 / 2017-04-04 -================== +# 3.1.1 / 2017-04-04 -- Fixed `files` property in `package.json`; `lib/` folder wasn't included in v3.1.0 +* Fixed `files` property in `package.json`; `lib/` folder wasn't included in v3.1.0 -3.1.0 / 2017-04-04 -================== +# 3.1.0 / 2017-04-04 -- Improved incremental rebuilds for better performance in watch mode. -- Switched to `read-cache` for file reading for better performance. -- Set a dummy filename when reading from stdin to help plugins like autoprefixer find config files. -- Updated `fs-promise` dependency. +* Improved incremental rebuilds for better performance in watch mode. +* Switched to `read-cache` for file reading for better performance. +* Set a dummy filename when reading from stdin to help plugins like autoprefixer find config files. +* Updated `fs-promise` dependency. -3.0.0 / 2017-03-15 -========== +# 3.0.0 / 2017-03-15 ## Changes since 3.0.0-beta ### Breaking Changes -- Don't exit on `CssSyntaxError` in watch mode. v2 behaved this way, but v3.0.0-beta didn't. -- Error out if `from` or `to` options are set in the config file. Use command line arguments instead. +* Don't exit on `CssSyntaxError` in watch mode. v2 behaved this way, but v3.0.0-beta didn't. +* Error out if `from` or `to` options are set in the config file. Use command line arguments instead. ### New Features -- Add `--poll` option. v2 had this, however, this new implementation removes the capability to set the interval, which was supported in v2. +* Add `--poll` option. v2 had this, however, this new implementation removes the capability to set the interval, which was supported in v2. ### Bugfixes -- Set `from` option for correct sourcemaps -- Fix `--watch`'s glob handling -- Fix error handling - +* Set `from` option for correct sourcemaps +* Fix `--watch`'s glob handling +* Fix error handling ## Changes since v2.6.0 ### Breaking Changes -- Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. -- Can't set input files in config file; pass input files on the command line instead. -- `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. -- Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. -- Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. -- Removed `--log` flag; this behavior is now default. -- Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. -- Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. -- Changed behavior of the `--poll` option; no longer accepts an integer `interval`. + +* Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. +* Can't set input files in config file; pass input files on the command line instead. +* `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. +* Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. +* Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. +* Removed `--log` flag; this behavior is now default. +* Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. +* Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. +* Changed behavior of the `--poll` option; no longer accepts an integer `interval`. ### New Features -- `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. -- `--env` allows you to set `NODE_ENV` in a cross-platform manner. + +* `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. +* `--env` allows you to set `NODE_ENV` in a cross-platform manner. Migration guide for upgrading from v2: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-to-v3 -3.0.0-beta / 2017-03-17 -========== +# 3.0.0-beta / 2017-03-17 ## Breaking Changes -- Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. -- Can't set input files in config file; pass input files on the command line instead. -- `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. -- Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. -- Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. -- Removed `--log` flag; this behavior is now default. -- Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. -- Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. + +* Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. +* Can't set input files in config file; pass input files on the command line instead. +* `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. +* Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. +* Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. +* Removed `--log` flag; this behavior is now default. +* Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. +* Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. ## New Features -- `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. -- `--env` allows you to set `NODE_ENV` in a cross-platform manner. + +* `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. +* `--env` allows you to set `NODE_ENV` in a cross-platform manner. Migration guide: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-to-v3 -2.6.0 / 2016-08-30 -================== +# 2.6.0 / 2016-08-30 - * Add log option - * Update postcss-import to v8.1.2 from v7.1.0 - * Update globby to v4.1.0 from v3.0.1 - * Update postcss-url to v5.1.2 from v4.0.0 - * Update jshint to v2.9.2 from v2.6.3 - * Update chokidar to v1.5.1 from v1.0.3 - * Update yargs to v4.7.1 from v3.32.0 - * Support es6 export - * Allow running without plugins - * Add test for --poll - * Add --poll flag +* Add log option +* Update postcss-import to v8.1.2 from v7.1.0 +* Update globby to v4.1.0 from v3.0.1 +* Update postcss-url to v5.1.2 from v4.0.0 +* Update jshint to v2.9.2 from v2.6.3 +* Update chokidar to v1.5.1 from v1.0.3 +* Update yargs to v4.7.1 from v3.32.0 +* Support es6 export +* Allow running without plugins +* Add test for --poll +* Add --poll flag -2.5.2 / 2016-04-18 -================== +# 2.5.2 / 2016-04-18 - * Fix typo in help message: -use => [--use|-u] - * npm install --save mkdirp - * Support mkdirp to create dest path if it doesn't exists - * Fix booleans in config file +* Fix typo in help message: -use => [--use|-u] +* npm install --save mkdirp +* Support mkdirp to create dest path if it doesn't exists +* Fix booleans in config file -2.5.1 / 2016-02-11 -================== +# 2.5.1 / 2016-02-11 - * fix `input` argument +* fix `input` argument -2.5.0 / 2016-01-30 -================== +# 2.5.0 / 2016-01-30 - * move to postcss/postcss-cli repository - * Update Readme.md +* move to postcss/postcss-cli repository +* Update Readme.md -2.4.1 / 2016-01-27 -================== +# 2.4.1 / 2016-01-27 - * improve warning disply format +* improve warning disply format -2.4.0 / 2016-01-15 -================== +# 2.4.0 / 2016-01-15 - * add support for source maps +* add support for source maps -2.3.3 / 2015-12-28 -================== +# 2.3.3 / 2015-12-28 - * add usage example for `local-plugins` option in config file +* add usage example for `local-plugins` option in config file -2.3.2 / 2015-10-27 -================== +# 2.3.2 / 2015-10-27 - * auto-configure postcss-import support - * add support for watching multiple entry points +* auto-configure postcss-import support +* add support for watching multiple entry points -2.3.1 / 2015-10-25 -================== +# 2.3.1 / 2015-10-25 - * update Travis config - * upgrade postcss-import dependency - fix deprecation warnings during make test-watch +* update Travis config +* upgrade postcss-import dependency - fix deprecation warnings during make test-watch -2.3.0 / 2015-10-24 -================== +# 2.3.0 / 2015-10-24 - * add --local-plugins option that lets postcss-cli to look for plugins in current directory +* add --local-plugins option that lets postcss-cli to look for plugins in current directory -2.2.0 / 2015-10-09 -================== +# 2.2.0 / 2015-10-09 - * add support for --replace|-r - if used input files are replaced with generated output - * refactor support for custom syntax options +* add support for --replace|-r - if used input files are replaced with generated output +* refactor support for custom syntax options -2.1.1 / 2015-10-08 -================== +# 2.1.1 / 2015-10-08 - * add globby to support wildcards in Windows - * remove obsolete note on postcss-import compatibility +* add globby to support wildcards in Windows +* remove obsolete note on postcss-import compatibility -2.1.0 / 2015-09-01 -================== +# 2.1.0 / 2015-09-01 - * add support for PostCSS 5.0 custom syntax options +* add support for PostCSS 5.0 custom syntax options -2.0.0 / 2015-08-24 -================== +# 2.0.0 / 2015-08-24 - * remove support for --safe option - * switch to using postcss 5.x +* remove support for --safe option +* switch to using postcss 5.x -1.5.0 / 2015-07-20 -================== +# 1.5.0 / 2015-07-20 - * add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change - * update neo-async dependency to released version - * update postcss-url dependency (used in tests only) +* add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change +* update neo-async dependency to released version +* update postcss-url dependency (used in tests only) -1.4.0 / 2015-07-12 -================== +# 1.4.0 / 2015-07-12 - * allow specifying input file via config file - * allow specifying -u|--use via config file +* allow specifying input file via config file +* allow specifying -u|--use via config file -1.3.1 / 2015-05-03 -================== +# 1.3.1 / 2015-05-03 - * update npm keyword: postcssrunner -> postcss-runner +* update npm keyword: postcssrunner -> postcss-runner -1.3.0 / 2015-04-28 -================== +# 1.3.0 / 2015-04-28 - * add support for stdin/stdout if no input/output file specified +* add support for stdin/stdout if no input/output file specified -1.2.1 / 2015-04-20 -================== +# 1.2.1 / 2015-04-20 - * fix typo in readme +* fix typo in readme -1.2.0 / 2015-04-02 -================== +# 1.2.0 / 2015-04-02 - * display warnings and errors - * stop testing on node 0.10 +* display warnings and errors +* stop testing on node 0.10 -1.1.0 / 2015-03-28 -================== +# 1.1.0 / 2015-03-28 - * prefer postcss async API if available +* prefer postcss async API if available -1.0.0 / 2015-03-22 -================== +# 1.0.0 / 2015-03-22 - * use official yargs version - * add support for multiple input files +* use official yargs version +* add support for multiple input files -0.3.0 / 2015-03-19 -================== +# 0.3.0 / 2015-03-19 - * support JS format as plugins config +* support JS format as plugins config -0.2.0 / 2015-03-13 -================== +# 0.2.0 / 2015-03-13 - * use autoprefixer instead of autoprefixer-core - * change short options for --use from `p` to `u` - * add -v|--version support - * add --safe option to enable postcss safe mode +* use autoprefixer instead of autoprefixer-core +* change short options for --use from `p` to `u` +* add -v|--version support +* add --safe option to enable postcss safe mode -0.1.0 / 2015-03-11 -================== +# 0.1.0 / 2015-03-11 - * initial implementaion +* initial implementaion diff --git a/README.md b/README.md index 49b8bf8..8351fdc 100644 --- a/README.md +++ b/README.md @@ -70,18 +70,19 @@ Input files may contain globs. If you pass an input directory, it will process all files in the directory and any subdirectories. ``` -> ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). +> ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). ### [Config](https://github.com/michael-ciniawsky/postcss-load-config) If you need to pass options to your plugins, or have a long plugin chain, you'll want to use a configuration file. **postcss.config.js** + ```js module.exports = { parser: 'sugarss', plugins: [ - require('postcss-import')({...options}), + require('postcss-import')({ ...options }), require('postcss-url')({ url: 'copy', useHash: true }) ] } @@ -93,58 +94,53 @@ Note that you **can not** set the `from` or `to` options for postcss in the conf For more advanced usage it's recommend to to use a function in `postcss.config.js`, this gives you access to the CLI context to dynamically apply options and plugins **per file** -|Name|Type|Default|Description| -|:--:|:--:|:-----:|:----------| -|`env`|`{String}`|`'development'`|process.env.NODE_ENV| -|`file`|`{Object}`|`dirname, basename, extname`|File| -|`options`|`{Object}`|`map, parser, syntax, stringifier`|PostCSS Options| +| Name | Type | Default | Description | +| :-------: | :--------: | :--------------------------------: | :------------------- | +| `env` | `{String}` | `'development'` | process.env.NODE_ENV | +| `file` | `{Object}` | `dirname, basename, extname` | File | +| `options` | `{Object}` | `map, parser, syntax, stringifier` | PostCSS Options | **postcss.config.js** + ```js -module.exports = (ctx) => ({ +module.exports = ctx => ({ map: ctx.options.map, parser: ctx.file.extname === '.sss' ? 'sugarss' : false, plugins: { 'postcss-import': { root: ctx.file.dirname }, - 'cssnano': ctx.env === 'production' ? {} : false + cssnano: ctx.env === 'production' ? {} : false } }) ``` -> ⚠️ If you want to set options via CLI, it's mandatory to reference `ctx.options` in `postcss.config.js` - +> ⚠️ If you want to set options via CLI, it's mandatory to reference `ctx.options` in `postcss.config.js` ```bash postcss input.sss -p sugarss -o output.css -m ``` **postcss.config.js** + ```js -module.exports = (ctx) => ({ +module.exports = ctx => ({ map: ctx.options.map, parser: ctx.options.parser, plugins: { 'postcss-import': { root: ctx.file.dirname }, - 'cssnano': ctx.env === 'production' ? {} : false + cssnano: ctx.env === 'production' ? {} : false } }) ``` - [npm]: https://img.shields.io/npm/v/postcss-cli.svg [npm-url]: https://npmjs.com/package/postcss-cli - [node]: https://img.shields.io/node/v/postcss-cli.svg [node-url]: https://nodejs.org/ - [deps]: https://img.shields.io/gemnasium/postcss/postcss-cli.svg [deps-url]: https://gemnasium.com/postcss/postcss-cli - [tests]: http://img.shields.io/travis/postcss/postcss-cli/master.svg [tests-url]: https://travis-ci.org/postcss/postcss-cli - [cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg [cover-url]: https://coveralls.io/github/postcss/postcss-cli - [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg [chat-url]: https://gitter.im/postcss/postcss diff --git a/package.json b/package.json index 6541366..15713dd 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "postcss": "./bin/postcss" }, "scripts": { - "ci": "eslint . && nyc ava -v", + "ci": "eslint . && nyc ava -v && npm run prettier -- --list-different", "clean": "node test/helpers/clean.js", - "format": "eslint . --fix", + "prettier": "prettier --single-quote --no-semi **/*.{js,md}", + "format": "npm run prettier -- --write && eslint . --fix", "pretest": "npm run clean && npm run format", "test": "nyc ava -v" }, @@ -35,11 +36,10 @@ "coveralls": "^3.0.0", "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", - "eslint-plugin-prettier": "^2.1.2", "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.9.2", + "prettier": "1.10.2", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" From 916c9b8d9fd3a0b7266e1a63d8d0771fb9c95b22 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 6 Feb 2018 12:32:36 -0500 Subject: [PATCH 045/251] Don't mutate global config object Closes #152 --- index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index f21a040..e1791a9 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ const output = argv.output if (argv.map) argv.map = { inline: false } -let config = { +const cliConfig = { options: { map: argv.map !== undefined ? argv.map : { inline: true }, parser: argv.parser ? require(argv.parser) : undefined, @@ -42,6 +42,8 @@ let config = { : [] } +let configFile + if (argv.env) process.env.NODE_ENV = argv.env if (argv.config) argv.config = path.resolve(argv.config) @@ -90,7 +92,7 @@ Promise.resolve() interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100 }) - if (config.file) watcher.add(config.file) + if (configFile) watcher.add(configFile) watcher.on('ready', printMessage).on('change', file => { let recompile = [] @@ -117,7 +119,7 @@ Promise.resolve() }) function rc(ctx, path) { - if (argv.use) return Promise.resolve() + if (argv.use) return Promise.resolve(cliConfig) // Set argv: false to keep cosmiconfig from attempting to read the --config // flag from process.argv @@ -128,7 +130,8 @@ function rc(ctx, path) { 'Config Error: Can not set from or to options in config file, use CLI arguments instead' ) } - config = rc + configFile = rc.file + return rc }) .catch(err => { if (err.message.indexOf('No PostCSS Config found') === -1) throw err @@ -153,7 +156,7 @@ function files(files) { } function css(css, file) { - const ctx = { options: config.options } + const ctx = { options: cliConfig.options } if (file !== 'stdin') { ctx.file = { @@ -175,7 +178,8 @@ function css(css, file) { printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`) return rc(ctx, argv.config) - .then(() => { + .then(config => { + config = config || cliConfig const options = config.options if (file === 'stdin' && output) file = output From dc5df269d37de61fa7b7cff1ab3af9dfc209b5bf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 6 Feb 2018 13:16:39 -0500 Subject: [PATCH 046/251] Rename authors to contributors in package.json to comply with spec --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15713dd..182d57f 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "postcss", "postcss-runner" ], - "authors": [ + "contributors": [ { "name": "Michael Ciniawky", "email": "michael.ciniawsky@gmail.com" From 1bf8822f26c22f4cda87be302daac78c9ff90066 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 6 Feb 2018 13:17:08 -0500 Subject: [PATCH 047/251] 5.0.0 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd27f8b..f54e5ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 5.0.0 / 2018-02-06 + +* Now allows passing a directory as the input (all files in the directory will be processed) +* The CLI is now silent by default; added `--verbose` flag for if you want noisy logs +* Doesn't exit watch mode when there's an error in the plugin chain +* Removed non-obvious shorthand arguments (`-x`, `-p`, `-s`, `-t`, `-e`, `-b`, & `-c`). Also removed `-v` as an alias for `--version`. +* Prevent stupid option combinations like `--dir` & `-o`, and `--watch` & `--replace` +* Doesn't allow `--watch` when writing to STDOUT + # 4.1.1 / 2017-08-17 * Fixed bug with `--config` diff --git a/package.json b/package.json index 182d57f..8cd8d36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "4.1.1", + "version": "5.0.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 97627f58af9375fdd416a710214f7bd95491fcc7 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 6 Feb 2018 21:24:03 -0500 Subject: [PATCH 048/251] Remove unused devDeps --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 8cd8d36..f3700f0 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,8 @@ "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", "nyc": "^11.0.2", - "per-env": "^1.0.2", "postcss-import": "^11.0.0", "prettier": "1.10.2", - "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From 9a6bdb1ed9659873f0c4dc85393293ebf1b11885 Mon Sep 17 00:00:00 2001 From: Sylvain Pollet-Villard Date: Sat, 10 Feb 2018 03:35:05 +0100 Subject: [PATCH 049/251] Fix tests on Windows (#196) --- test/base.js | 2 +- test/helpers/cli.js | 7 +++---- test/helpers/read.js | 2 +- test/stdin.js | 7 +++---- test/stdout.js | 11 ++++++----- test/watch.js | 33 ++++++++++++++------------------- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/test/base.js b/test/base.js index 5402d31..aba6102 100644 --- a/test/base.js +++ b/test/base.js @@ -9,7 +9,7 @@ test('--base --dir works', async t => { const dir = tmp() const { error, stderr } = await cli([ - 'test/fixtures/base/**/*.css', + '"test/fixtures/base/**/*.css"', '--dir', dir, '--base', diff --git a/test/helpers/cli.js b/test/helpers/cli.js index d6027ae..fef2086 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,11 +1,10 @@ import path from 'path' -import { execFile } from 'child_process' +import { exec } from 'child_process' export default function(args, cwd) { return new Promise(resolve => { - execFile( - path.resolve('bin/postcss'), - args, + exec( + `node ${path.resolve('bin/postcss')} ${args.join(' ')}`, { cwd }, (err, stdout, stderr) => { resolve({ diff --git a/test/helpers/read.js b/test/helpers/read.js index 59f727d..ead014d 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,5 +1,5 @@ import { readFile } from 'fs-extra' export default function(path) { - return readFile(path, 'utf8') + return readFile(path, 'utf8').then(content => content.replace(/\r\n/g, '\n')) // normalize line endings on Windows } diff --git a/test/stdin.js b/test/stdin.js index 7e6907a..86e15bf 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -2,7 +2,7 @@ import test from 'ava' import fs from 'fs-extra' import path from 'path' -import { execFile } from 'child_process' +import { exec } from 'child_process' import tmp from './helpers/tmp.js' import read from './helpers/read.js' @@ -10,9 +10,8 @@ import read from './helpers/read.js' test.cb('reads from stdin', t => { const output = tmp('output.css') - const cp = execFile( - path.resolve('bin/postcss'), - ['-o', output, '--no-map'], + const cp = exec( + `node ${path.resolve('bin/postcss')} -o ${output} --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) diff --git a/test/stdout.js b/test/stdout.js index 388968a..da1401a 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -2,18 +2,19 @@ import test from 'ava' import fs from 'fs-extra' import path from 'path' -import { execFile } from 'child_process' +import { exec } from 'child_process' import read from './helpers/read.js' test.cb('writes to stdout', t => { - const cp = execFile( - path.resolve('bin/postcss'), - ['--parser', 'sugarss', '-u', 'postcss-import', '--no-map'], + const cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} --parser sugarss -u postcss-import --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) - Promise.all([stdout, read('test/fixtures/s.css')]) + Promise.all([stdout.replace(/\r\n/g, '\n'), read('test/fixtures/s.css')]) .then(([a, e]) => { t.is(a, e) t.end() diff --git a/test/watch.js b/test/watch.js index b13d532..b98fa6b 100644 --- a/test/watch.js +++ b/test/watch.js @@ -2,7 +2,7 @@ import test from 'ava' import fs from 'fs-extra' import path from 'path' -import { exec, execFile } from 'child_process' +import { exec } from 'child_process' import chokidar from 'chokidar' import ENV from './helpers/env.js' @@ -48,7 +48,9 @@ test.cb.skip('--watch works', t => { watcher.on('ready', () => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( - `${path.resolve('bin/postcss')} "*.css" -o output.css --no-map -w`, + `node ${path.resolve( + 'bin/postcss' + )} "*.css" -o output.css --no-map -w`, { cwd: dir } ) cp.on('error', t.end) @@ -124,9 +126,10 @@ test.cb.skip('--watch postcss.config.js', t => { // Start postcss-cli: watcher.on('ready', () => { - cp = execFile( - path.resolve('bin/postcss'), - ['import.css', '-o', 'output.css', '-w', '--no-map'], + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} import.css -o output.css -w --no-map`, { cwd: dir } ) @@ -193,17 +196,10 @@ test.cb.skip('--watch dependencies', t => { // Start postcss-cli: watcher.on('ready', () => { - cp = execFile( - path.resolve('bin/postcss'), - [ - 'import.css', - '-o', - 'output.css', - '-u', - 'postcss-import', - '-w', - '--no-map' - ], + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} import.css -o output.css -u postcss-import -w --no-map`, { cwd: dir } ) @@ -252,9 +248,8 @@ test.cb.skip("--watch doesn't exit on CssSyntaxError", t => { }) let killed = false - const cp = execFile( - path.resolve('bin/postcss'), - ['a.css', '-o', 'output.css', '-w', '--no-map'], + const cp = exec( + `node ${path.resolve('bin/postcss')} a.css -o output.css -w --no-map`, { cwd: dir } ) cp.on('error', t.end) From 52e683454bf9a97c088a9fefe6db56eb0dc219fa Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 13 Feb 2018 09:31:10 -0500 Subject: [PATCH 050/251] Update globby to version 8.0.0 (#197) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f3700f0..3b211bd 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependency-graph": "^0.7.0", "fs-extra": "^5.0.0", "get-stdin": "^5.0.1", - "globby": "^7.1.1", + "globby": "^8.0.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", "postcss-reporter": "^5.0.0", From 92296be8e6aa55b9868462af4d87d6eb6e038a02 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 27 Feb 2018 07:57:40 -0500 Subject: [PATCH 051/251] Fix test --- test/replace.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/replace.js b/test/replace.js index 38127ae..ba2a15b 100644 --- a/test/replace.js +++ b/test/replace.js @@ -17,8 +17,9 @@ test('--replace works', async t => { fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')) ]) + // XXX: Should be able to pass output instead of dir here, but this test env is weird const { error, stderr } = await cli([ - output, + dir, '--replace', '-u', 'postcss-import', From 7769de5631bb4796a7398d2bd59079dcea84804b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 27 Feb 2018 08:26:22 -0500 Subject: [PATCH 052/251] Update prettier to version 1.11.0 (#200) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b211bd..726a878 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "0.0.2", "nyc": "^11.0.2", "postcss-import": "^11.0.0", - "prettier": "1.10.2", + "prettier": "1.11.0", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From 60d215756d9585d1e1fa177de067c89dda284d89 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 2 Mar 2018 13:37:38 -0500 Subject: [PATCH 053/251] Update get-stdin to version 6.0.0 (#202) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 726a878..a5b15ec 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "chokidar": "^2.0.0", "dependency-graph": "^0.7.0", "fs-extra": "^5.0.0", - "get-stdin": "^5.0.1", + "get-stdin": "^6.0.0", "globby": "^8.0.0", "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", From 74119f479d89ac6cff21a9ddcda69ac408beec0e Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 12 Apr 2018 08:09:00 -0400 Subject: [PATCH 054/251] Update prettier to version 1.12.0 (#206) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a5b15ec..2f5f8cb 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "0.0.2", "nyc": "^11.0.2", "postcss-import": "^11.0.0", - "prettier": "1.11.0", + "prettier": "1.12.0", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From 39d8dbd59d220c02e205b86f71b2ace6321bf7d0 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 17 Apr 2018 07:07:34 -0400 Subject: [PATCH 055/251] Update prettier to version 1.12.1 (#208) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f5f8cb..46920df 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "0.0.2", "nyc": "^11.0.2", "postcss-import": "^11.0.0", - "prettier": "1.12.0", + "prettier": "1.12.1", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From d71fda944c8d9468994564914b2102b8604b0fd7 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 28 May 2018 09:23:23 -0400 Subject: [PATCH 056/251] Update prettier to version 1.13.0 (#216) Fix formatting --- CHANGELOG.md | 192 +++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f54e5ed..4f5db19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,40 +1,40 @@ # 5.0.0 / 2018-02-06 -* Now allows passing a directory as the input (all files in the directory will be processed) -* The CLI is now silent by default; added `--verbose` flag for if you want noisy logs -* Doesn't exit watch mode when there's an error in the plugin chain -* Removed non-obvious shorthand arguments (`-x`, `-p`, `-s`, `-t`, `-e`, `-b`, & `-c`). Also removed `-v` as an alias for `--version`. -* Prevent stupid option combinations like `--dir` & `-o`, and `--watch` & `--replace` -* Doesn't allow `--watch` when writing to STDOUT +- Now allows passing a directory as the input (all files in the directory will be processed) +- The CLI is now silent by default; added `--verbose` flag for if you want noisy logs +- Doesn't exit watch mode when there's an error in the plugin chain +- Removed non-obvious shorthand arguments (`-x`, `-p`, `-s`, `-t`, `-e`, `-b`, & `-c`). Also removed `-v` as an alias for `--version`. +- Prevent stupid option combinations like `--dir` & `-o`, and `--watch` & `--replace` +- Doesn't allow `--watch` when writing to STDOUT # 4.1.1 / 2017-08-17 -* Fixed bug with `--config` -* Upgraded dependencies +- Fixed bug with `--config` +- Upgraded dependencies # 4.1.0 / 2017-06-10 -* Can now pass a number to `--poll` to set poll interval -* Updated `postcss-reporter` dependency to v4.0.0 +- Can now pass a number to `--poll` to set poll interval +- Updated `postcss-reporter` dependency to v4.0.0 # 4.0.0 / 2017-05-09 -* **BREAKING:** Upgrade postcss to v6.x +- **BREAKING:** Upgrade postcss to v6.x # 3.2.0 / 2017-04-21 -* Added `--base` CLI option for keeping directory structure +- Added `--base` CLI option for keeping directory structure # 3.1.1 / 2017-04-04 -* Fixed `files` property in `package.json`; `lib/` folder wasn't included in v3.1.0 +- Fixed `files` property in `package.json`; `lib/` folder wasn't included in v3.1.0 # 3.1.0 / 2017-04-04 -* Improved incremental rebuilds for better performance in watch mode. -* Switched to `read-cache` for file reading for better performance. -* Set a dummy filename when reading from stdin to help plugins like autoprefixer find config files. -* Updated `fs-promise` dependency. +- Improved incremental rebuilds for better performance in watch mode. +- Switched to `read-cache` for file reading for better performance. +- Set a dummy filename when reading from stdin to help plugins like autoprefixer find config files. +- Updated `fs-promise` dependency. # 3.0.0 / 2017-03-15 @@ -42,37 +42,37 @@ ### Breaking Changes -* Don't exit on `CssSyntaxError` in watch mode. v2 behaved this way, but v3.0.0-beta didn't. -* Error out if `from` or `to` options are set in the config file. Use command line arguments instead. +- Don't exit on `CssSyntaxError` in watch mode. v2 behaved this way, but v3.0.0-beta didn't. +- Error out if `from` or `to` options are set in the config file. Use command line arguments instead. ### New Features -* Add `--poll` option. v2 had this, however, this new implementation removes the capability to set the interval, which was supported in v2. +- Add `--poll` option. v2 had this, however, this new implementation removes the capability to set the interval, which was supported in v2. ### Bugfixes -* Set `from` option for correct sourcemaps -* Fix `--watch`'s glob handling -* Fix error handling +- Set `from` option for correct sourcemaps +- Fix `--watch`'s glob handling +- Fix error handling ## Changes since v2.6.0 ### Breaking Changes -* Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. -* Can't set input files in config file; pass input files on the command line instead. -* `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. -* Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. -* Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. -* Removed `--log` flag; this behavior is now default. -* Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. -* Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. -* Changed behavior of the `--poll` option; no longer accepts an integer `interval`. +- Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. +- Can't set input files in config file; pass input files on the command line instead. +- `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. +- Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. +- Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. +- Removed `--log` flag; this behavior is now default. +- Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. +- Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. +- Changed behavior of the `--poll` option; no longer accepts an integer `interval`. ### New Features -* `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. -* `--env` allows you to set `NODE_ENV` in a cross-platform manner. +- `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. +- `--env` allows you to set `NODE_ENV` in a cross-platform manner. Migration guide for upgrading from v2: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-to-v3 @@ -80,145 +80,145 @@ Migration guide for upgrading from v2: https://github.com/postcss/postcss-cli/wi ## Breaking Changes -* Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. -* Can't set input files in config file; pass input files on the command line instead. -* `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. -* Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. -* Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. -* Removed `--log` flag; this behavior is now default. -* Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. -* Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. +- Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. +- Can't set input files in config file; pass input files on the command line instead. +- `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. +- Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. +- Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. +- Removed `--log` flag; this behavior is now default. +- Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. +- Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. ## New Features -* `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. -* `--env` allows you to set `NODE_ENV` in a cross-platform manner. +- `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. +- `--env` allows you to set `NODE_ENV` in a cross-platform manner. Migration guide: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-to-v3 # 2.6.0 / 2016-08-30 -* Add log option -* Update postcss-import to v8.1.2 from v7.1.0 -* Update globby to v4.1.0 from v3.0.1 -* Update postcss-url to v5.1.2 from v4.0.0 -* Update jshint to v2.9.2 from v2.6.3 -* Update chokidar to v1.5.1 from v1.0.3 -* Update yargs to v4.7.1 from v3.32.0 -* Support es6 export -* Allow running without plugins -* Add test for --poll -* Add --poll flag +- Add log option +- Update postcss-import to v8.1.2 from v7.1.0 +- Update globby to v4.1.0 from v3.0.1 +- Update postcss-url to v5.1.2 from v4.0.0 +- Update jshint to v2.9.2 from v2.6.3 +- Update chokidar to v1.5.1 from v1.0.3 +- Update yargs to v4.7.1 from v3.32.0 +- Support es6 export +- Allow running without plugins +- Add test for --poll +- Add --poll flag # 2.5.2 / 2016-04-18 -* Fix typo in help message: -use => [--use|-u] -* npm install --save mkdirp -* Support mkdirp to create dest path if it doesn't exists -* Fix booleans in config file +- Fix typo in help message: -use => [--use|-u] +- npm install --save mkdirp +- Support mkdirp to create dest path if it doesn't exists +- Fix booleans in config file # 2.5.1 / 2016-02-11 -* fix `input` argument +- fix `input` argument # 2.5.0 / 2016-01-30 -* move to postcss/postcss-cli repository -* Update Readme.md +- move to postcss/postcss-cli repository +- Update Readme.md # 2.4.1 / 2016-01-27 -* improve warning disply format +- improve warning disply format # 2.4.0 / 2016-01-15 -* add support for source maps +- add support for source maps # 2.3.3 / 2015-12-28 -* add usage example for `local-plugins` option in config file +- add usage example for `local-plugins` option in config file # 2.3.2 / 2015-10-27 -* auto-configure postcss-import support -* add support for watching multiple entry points +- auto-configure postcss-import support +- add support for watching multiple entry points # 2.3.1 / 2015-10-25 -* update Travis config -* upgrade postcss-import dependency - fix deprecation warnings during make test-watch +- update Travis config +- upgrade postcss-import dependency - fix deprecation warnings during make test-watch # 2.3.0 / 2015-10-24 -* add --local-plugins option that lets postcss-cli to look for plugins in current directory +- add --local-plugins option that lets postcss-cli to look for plugins in current directory # 2.2.0 / 2015-10-09 -* add support for --replace|-r - if used input files are replaced with generated output -* refactor support for custom syntax options +- add support for --replace|-r - if used input files are replaced with generated output +- refactor support for custom syntax options # 2.1.1 / 2015-10-08 -* add globby to support wildcards in Windows -* remove obsolete note on postcss-import compatibility +- add globby to support wildcards in Windows +- remove obsolete note on postcss-import compatibility # 2.1.0 / 2015-09-01 -* add support for PostCSS 5.0 custom syntax options +- add support for PostCSS 5.0 custom syntax options # 2.0.0 / 2015-08-24 -* remove support for --safe option -* switch to using postcss 5.x +- remove support for --safe option +- switch to using postcss 5.x # 1.5.0 / 2015-07-20 -* add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change -* update neo-async dependency to released version -* update postcss-url dependency (used in tests only) +- add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change +- update neo-async dependency to released version +- update postcss-url dependency (used in tests only) # 1.4.0 / 2015-07-12 -* allow specifying input file via config file -* allow specifying -u|--use via config file +- allow specifying input file via config file +- allow specifying -u|--use via config file # 1.3.1 / 2015-05-03 -* update npm keyword: postcssrunner -> postcss-runner +- update npm keyword: postcssrunner -> postcss-runner # 1.3.0 / 2015-04-28 -* add support for stdin/stdout if no input/output file specified +- add support for stdin/stdout if no input/output file specified # 1.2.1 / 2015-04-20 -* fix typo in readme +- fix typo in readme # 1.2.0 / 2015-04-02 -* display warnings and errors -* stop testing on node 0.10 +- display warnings and errors +- stop testing on node 0.10 # 1.1.0 / 2015-03-28 -* prefer postcss async API if available +- prefer postcss async API if available # 1.0.0 / 2015-03-22 -* use official yargs version -* add support for multiple input files +- use official yargs version +- add support for multiple input files # 0.3.0 / 2015-03-19 -* support JS format as plugins config +- support JS format as plugins config # 0.2.0 / 2015-03-13 -* use autoprefixer instead of autoprefixer-core -* change short options for --use from `p` to `u` -* add -v|--version support -* add --safe option to enable postcss safe mode +- use autoprefixer instead of autoprefixer-core +- change short options for --use from `p` to `u` +- add -v|--version support +- add --safe option to enable postcss safe mode # 0.1.0 / 2015-03-11 -* initial implementaion +- initial implementaion diff --git a/package.json b/package.json index 46920df..c7cdb6b 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "0.0.2", "nyc": "^11.0.2", "postcss-import": "^11.0.0", - "prettier": "1.12.1", + "prettier": "1.13.0", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From eb9aea98bf43924ff36b4656177c018229f6884e Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 1 Jun 2018 17:05:38 +0300 Subject: [PATCH 057/251] Shallow copy options object (#218) * Shallow copy options object * Add test for glob patterns --- index.js | 2 +- test/fixtures/glob/a.css | 3 +++ test/fixtures/glob/b.css | 3 +++ test/fixtures/glob/s.css | 3 +++ test/glob.js | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/glob/a.css create mode 100644 test/fixtures/glob/b.css create mode 100644 test/fixtures/glob/s.css create mode 100644 test/glob.js diff --git a/index.js b/index.js index e1791a9..e9193ca 100644 --- a/index.js +++ b/index.js @@ -180,7 +180,7 @@ function css(css, file) { return rc(ctx, argv.config) .then(config => { config = config || cliConfig - const options = config.options + const options = Object.assign({}, config.options) if (file === 'stdin' && output) file = output diff --git a/test/fixtures/glob/a.css b/test/fixtures/glob/a.css new file mode 100644 index 0000000..5451a33 --- /dev/null +++ b/test/fixtures/glob/a.css @@ -0,0 +1,3 @@ +.a { + color: red; +} diff --git a/test/fixtures/glob/b.css b/test/fixtures/glob/b.css new file mode 100644 index 0000000..14aa1f6 --- /dev/null +++ b/test/fixtures/glob/b.css @@ -0,0 +1,3 @@ +.b { + color: blue; +} diff --git a/test/fixtures/glob/s.css b/test/fixtures/glob/s.css new file mode 100644 index 0000000..e88d515 --- /dev/null +++ b/test/fixtures/glob/s.css @@ -0,0 +1,3 @@ +.a { + color: red +} diff --git a/test/glob.js b/test/glob.js new file mode 100644 index 0000000..32da650 --- /dev/null +++ b/test/glob.js @@ -0,0 +1,32 @@ +import test from 'ava' +import path from 'path' + +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' + +test('works with glob patterns', async t => { + const output = tmp() + + const { error, stderr } = await cli([ + 'test/fixtures/glob/*.css', + '-d', + output, + '--no-map' + ]) + + t.ifError(error, stderr) + + t.is( + await read(path.join(output, 'a.css')), + await read('test/fixtures/glob/a.css') + ) + t.is( + await read(path.join(output, 'b.css')), + await read('test/fixtures/glob/b.css') + ) + t.is( + await read(path.join(output, 's.css')), + await read('test/fixtures/glob/s.css') + ) +}) From a6bce74930616d1e6c6983d525f12bcc8fe4bd5b Mon Sep 17 00:00:00 2001 From: Andrew Moch Date: Sat, 16 Jun 2018 10:07:41 -0400 Subject: [PATCH 058/251] Updated readme.me to include information about glob-patterns (#211) * updated readme.me * updates to --help --- README.md | 6 ++++-- lib/args.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8351fdc..80d59dd 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Usage: postcss [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] postcss ... [OPTIONS] --dir [--watch|-w] postcss [OPTIONS] --dir [--watch|-w] + postcss [OPTIONS] --dir [--watch|-w] postcss ... [OPTIONS] --replace Basic options: @@ -59,6 +60,7 @@ Options: Examples: postcss input.css -o output.css Basic usage + postcss src/**/*.css --base src --dir build Glob Pattern & output cat input.css | postcss -u autoprefixer > output.css Piping input & output If no input files are passed, it reads from stdin. If neither -o, --dir, or @@ -66,8 +68,8 @@ If no input files are passed, it reads from stdin. If neither -o, --dir, or If there are multiple input files, the --dir or --replace option must be passed. -Input files may contain globs. If you pass an input directory, it will process -all files in the directory and any subdirectories. +Input files may contain globs (ie: src/**/*.css). If you pass an input directory, it will process +all files in the directory and any subdirectories, respecting the glob pattern. ``` > ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). diff --git a/lib/args.js b/lib/args.js index 7a2ca92..2e6e543 100644 --- a/lib/args.js +++ b/lib/args.js @@ -33,6 +33,7 @@ Usage: $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] $0 ... [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] + $0 [OPTIONS] --dir [--watch|-w] $0 ... [OPTIONS] --replace` ) .group( @@ -129,6 +130,7 @@ Usage: .version(version) .alias('h', 'help') .example('$0 input.css -o output.css', 'Basic usage') + .example('$0 src/**/*.css --base src --dir build', 'Glob Pattern & output') .example( 'cat input.css | $0 -u autoprefixer > output.css', 'Piping input & output' @@ -138,7 +140,7 @@ Usage: If there are multiple input files, the --dir or --replace option must be passed. -Input files may contain globs. If you pass an input directory, it will process all files in the directory and any subdirectories. +Input files may contain globs (ie: src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. For more details, please see https://github.com/postcss/postcss-cli` ).argv From cde8a2e4b6d381c44d8c2cf60896cdf55f0d23d1 Mon Sep 17 00:00:00 2001 From: mdmoreau Date: Mon, 18 Jun 2018 08:28:22 -0400 Subject: [PATCH 059/251] Add awaitWriteFinish to chokidar options (#221) --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e9193ca..764f2a4 100644 --- a/index.js +++ b/index.js @@ -89,7 +89,11 @@ Promise.resolve() printVerbose(chalk.dim('\nWaiting for file changes...')) const watcher = chokidar.watch(input.concat(dependencies(results)), { usePolling: argv.poll, - interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100 + interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100, + awaitWriteFinish: { + stabilityThreshold: 50, + pollInterval: 10 + } }) if (configFile) watcher.add(configFile) From 095ac7d1486b2124dbf46470f330b730cee23a8d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 18 Jun 2018 08:30:29 -0400 Subject: [PATCH 060/251] 5.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7cdb6b..fcc94aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "5.0.0", + "version": "5.0.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 39abad60bfe944e4f411cfd9794b0ea598e23444 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 18 Jun 2018 08:33:08 -0400 Subject: [PATCH 061/251] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f5db19..b7cdedf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 5.0.1 / 2018-06-18 + +- Shallow copy options object; fixes a few edge cases +- Adjust options for file watching to play better with some editors + # 5.0.0 / 2018-02-06 - Now allows passing a directory as the input (all files in the directory will be processed) From 5e0305a5e5b809068af6f9013d64da7b964a23ab Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 16:09:14 -0400 Subject: [PATCH 062/251] BREAKING: Drop Node 4 support --- .travis.yml | 1 - appveyor.yml | 2 +- package.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 915376c..ca220d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ node_js: - node - 8 - 6 - - 4 script: - npm run ci after_success: diff --git a/appveyor.yml b/appveyor.yml index 6450020..e3e585d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,8 @@ environment: matrix: + - nodejs_version: "10" - nodejs_version: "8" - nodejs_version: "6" - - nodejs_version: "4" version: "{build}" build: off diff --git a/package.json b/package.json index fcc94aa..bd28ef6 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "main": "index.js", "engines": { - "node": ">=4" + "node": ">=6" }, "bin": { "postcss": "./bin/postcss" From 6c1826eba0ea0e11164b4e58352d9d330169bb6b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 18 Jul 2018 16:10:12 -0400 Subject: [PATCH 063/251] Update postcss to version 7.0.0 (#229) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd28ef6..b151da9 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "fs-extra": "^5.0.0", "get-stdin": "^6.0.0", "globby": "^8.0.0", - "postcss": "^6.0.1", + "postcss": "^7.0.0", "postcss-load-config": "^1.1.0", "postcss-reporter": "^5.0.0", "pretty-hrtime": "^1.0.3", From 66c150b8983d2119553082a5d5084741730643af Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 16:19:31 -0400 Subject: [PATCH 064/251] Update eslint-config-problems to version 1.0.0 (#230) Closes #205 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b151da9..3cfb9d7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ava": "^0.25.0", "coveralls": "^3.0.0", "eslint": "^4.2.0", - "eslint-config-problems": "0.0.2", + "eslint-config-problems": "1.0.0", "nyc": "^11.0.2", "postcss-import": "^11.0.0", "prettier": "1.13.0", From 85445add4f165338e90cd9fd577dc3e3bc247835 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 16:20:40 -0400 Subject: [PATCH 065/251] Update fs-extra to version 7.0.0 (#231) Closes #213 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3cfb9d7..a13d62e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "chalk": "^2.1.0", "chokidar": "^2.0.0", "dependency-graph": "^0.7.0", - "fs-extra": "^5.0.0", + "fs-extra": "^7.0.0", "get-stdin": "^6.0.0", "globby": "^8.0.0", "postcss": "^7.0.0", From a29d24405573589f7b8d0caf04f243f4ed389ad7 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 16:21:09 -0400 Subject: [PATCH 066/251] Unpin prettier version to allow patch upgrades Closes #219 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a13d62e..72a0139 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "1.0.0", "nyc": "^11.0.2", "postcss-import": "^11.0.0", - "prettier": "1.13.0", + "prettier": "~1.13.0", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From 3b6b176f7ce828a6b2f1f5564f632577e13f13aa Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 18 Jul 2018 16:34:06 -0400 Subject: [PATCH 067/251] Update yargs to version 12.0.1 (#224) Remove hack since yargs bug is finally fixed --- lib/args.js | 6 ------ package.json | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/args.js b/lib/args.js index 2e6e543..23979d3 100644 --- a/lib/args.js +++ b/lib/args.js @@ -56,9 +56,6 @@ Usage: alias: 'replace', desc: 'Replace (overwrite) the input file', type: 'boolean', - // HACK: conflicts doesn't work with boolean opts correctly, so we do this - // See https://github.com/yargs/yargs/issues/929 - coerce: v => v || undefined, conflicts: ['output', 'dir'] }) .alias('map', 'm') @@ -72,9 +69,6 @@ Usage: alias: 'w', desc: 'Watch files for changes and recompile as needed', type: 'boolean', - // HACK: conflicts doesn't work with boolean opts correctly, so we do this - // See https://github.com/yargs/yargs/issues/929 - coerce: v => v || undefined, conflicts: 'replace' }) .option('env', { diff --git a/package.json b/package.json index 72a0139..a7fdaad 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "postcss-reporter": "^5.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "yargs": "^11.0.0" + "yargs": "^12.0.1" }, "devDependencies": { "ava": "^0.25.0", From 38970dd5a53b1141825149692f56ec07b9b4f3be Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 18 Jul 2018 16:35:23 -0400 Subject: [PATCH 068/251] Update eslint to version 5.0.0 (#223) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a7fdaad..75628c3 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "devDependencies": { "ava": "^0.25.0", "coveralls": "^3.0.0", - "eslint": "^4.2.0", + "eslint": "^5.0.0", "eslint-config-problems": "1.0.0", "nyc": "^11.0.2", "postcss-import": "^11.0.0", From a9db6d2ac0131dff424ed8b0826da348080230a8 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 18 Jul 2018 16:45:23 -0400 Subject: [PATCH 069/251] Update postcss-load-config to version 2.0.0 (#226) Remove usage of argv option; it has been removed from postcss-load-config and the default behavior is what we want --- index.js | 4 +--- package.json | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 764f2a4..d9423c0 100644 --- a/index.js +++ b/index.js @@ -125,9 +125,7 @@ Promise.resolve() function rc(ctx, path) { if (argv.use) return Promise.resolve(cliConfig) - // Set argv: false to keep cosmiconfig from attempting to read the --config - // flag from process.argv - return postcssrc(ctx, path, { argv: false }) + return postcssrc(ctx, path) .then(rc => { if (rc.options.from || rc.options.to) { error( diff --git a/package.json b/package.json index 75628c3..cc260c1 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "get-stdin": "^6.0.0", "globby": "^8.0.0", "postcss": "^7.0.0", - "postcss-load-config": "^1.1.0", + "postcss-load-config": "^2.0.0", "postcss-reporter": "^5.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From 1213eebe96ed231b302cc8ccf12e8d045266f38d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 17:26:15 -0400 Subject: [PATCH 070/251] Remove gemnasium badge --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 80d59dd..ca0877b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ [![npm][npm]][npm-url] [![node][node]][node-url] -[![deps][deps]][deps-url] [![Greenkeeper badge](https://badges.greenkeeper.io/postcss/postcss-cli.svg)](https://greenkeeper.io/) [![tests][tests]][tests-url] [![cover][cover]][cover-url] @@ -138,8 +137,6 @@ module.exports = ctx => ({ [npm-url]: https://npmjs.com/package/postcss-cli [node]: https://img.shields.io/node/v/postcss-cli.svg [node-url]: https://nodejs.org/ -[deps]: https://img.shields.io/gemnasium/postcss/postcss-cli.svg -[deps-url]: https://gemnasium.com/postcss/postcss-cli [tests]: http://img.shields.io/travis/postcss/postcss-cli/master.svg [tests-url]: https://travis-ci.org/postcss/postcss-cli [cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg From 89a83407966afdbecfa99a1fe20b470f49836ed7 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 17:46:54 -0400 Subject: [PATCH 071/251] Use some more modern JS features --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d9423c0..eed5d3e 100644 --- a/index.js +++ b/index.js @@ -17,10 +17,8 @@ const reporter = require('postcss-reporter/lib/formatter')() const argv = require('./lib/args') const depGraph = require('./lib/depGraph') -const dir = argv.dir - let input = argv._ -const output = argv.output +const { dir, output } = argv if (argv.map) argv.map = { inline: false } @@ -101,10 +99,10 @@ Promise.resolve() watcher.on('ready', printMessage).on('change', file => { let recompile = [] - if (~input.indexOf(file)) recompile.push(file) + if (input.includes(file)) recompile.push(file) recompile = recompile.concat( - depGraph.dependantsOf(file).filter(file => ~input.indexOf(file)) + depGraph.dependantsOf(file).filter(file => input.includes(file)) ) if (!recompile.length) recompile = input @@ -136,7 +134,7 @@ function rc(ctx, path) { return rc }) .catch(err => { - if (err.message.indexOf('No PostCSS Config found') === -1) throw err + if (!err.message.includes('No PostCSS Config found')) throw err }) } From 52bce09f731fcd60a6b1a176eaba548f4c89b740 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 18 Jul 2018 17:54:19 -0400 Subject: [PATCH 072/251] 6.0.0 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7cdedf..b56b05e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 6.0.0 / 2018-07-18 + +- Drop support for Node 4 +- Upgrade to postcss v7 ([release notes](https://github.com/postcss/postcss/blob/master/CHANGELOG.md#70-president-amy)) +- Upgrade to postcss-load-config v2 ([release notes](https://github.com/michael-ciniawsky/postcss-load-config/blob/master/CHANGELOG.md#200-2018-07-10)) + # 5.0.1 / 2018-06-18 - Shallow copy options object; fixes a few edge cases diff --git a/package.json b/package.json index cc260c1..df8c41d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "5.0.1", + "version": "6.0.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 3ec9b6e1ec3e008bf0b794b3693f646fceba1579 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 18 Jul 2018 19:55:54 -0400 Subject: [PATCH 073/251] Update eslint-config-problems to version 1.1.0 (#232) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df8c41d..4ea5560 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ava": "^0.25.0", "coveralls": "^3.0.0", "eslint": "^5.0.0", - "eslint-config-problems": "1.0.0", + "eslint-config-problems": "1.1.0", "nyc": "^11.0.2", "postcss-import": "^11.0.0", "prettier": "~1.13.0", From 5397879e429fc4c78e903513c0bdeb91c9eefe45 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 30 Jul 2018 09:56:26 -0400 Subject: [PATCH 074/251] Update prettier to version 1.14.0 (#234) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ea5560..5f3f04a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "1.1.0", "nyc": "^11.0.2", "postcss-import": "^11.0.0", - "prettier": "~1.13.0", + "prettier": "~1.14.0", "sugarss": "^1.0.0", "uuid": "^3.0.1" }, From d76803775f875b506b0633d8cfebdf7fbe5b1279 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 4 Aug 2018 14:41:27 -0400 Subject: [PATCH 075/251] Update postcss-import to version 12.0.0 (#235) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f3f04a..e37250e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "eslint": "^5.0.0", "eslint-config-problems": "1.1.0", "nyc": "^11.0.2", - "postcss-import": "^11.0.0", + "postcss-import": "^12.0.0", "prettier": "~1.14.0", "sugarss": "^1.0.0", "uuid": "^3.0.1" From c9d09591b71cbab30415cea86b03afd622f81ccf Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 8 Aug 2018 08:42:44 -0400 Subject: [PATCH 076/251] i.e. to e.g. (#236) --- README.md | 2 +- lib/args.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca0877b..5d0d4c3 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ If no input files are passed, it reads from stdin. If neither -o, --dir, or If there are multiple input files, the --dir or --replace option must be passed. -Input files may contain globs (ie: src/**/*.css). If you pass an input directory, it will process +Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. ``` diff --git a/lib/args.js b/lib/args.js index 23979d3..7476023 100644 --- a/lib/args.js +++ b/lib/args.js @@ -134,7 +134,7 @@ Usage: If there are multiple input files, the --dir or --replace option must be passed. -Input files may contain globs (ie: src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. +Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. For more details, please see https://github.com/postcss/postcss-cli` ).argv From 79840b65c2c7f3aff1d327b9f11a1a33c7f88209 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 11 Aug 2018 08:15:07 -0400 Subject: [PATCH 077/251] Update sugarss to version 2.0.0 (#237) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e37250e..01f491f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^11.0.2", "postcss-import": "^12.0.0", "prettier": "~1.14.0", - "sugarss": "^1.0.0", + "sugarss": "^2.0.0", "uuid": "^3.0.1" }, "files": [ From 85d4cc949f8170d3138d2e66c7f359df8b27d4c6 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 18 Aug 2018 16:45:32 -0400 Subject: [PATCH 078/251] Update postcss-reporter to version 6.0.0 (#238) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01f491f..17cdce6 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "globby": "^8.0.0", "postcss": "^7.0.0", "postcss-load-config": "^2.0.0", - "postcss-reporter": "^5.0.0", + "postcss-reporter": "^6.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "yargs": "^12.0.1" From 99ac19a12f7312b0435d5a87596a4a15b5f56fca Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Thu, 11 Oct 2018 18:04:13 +0300 Subject: [PATCH 079/251] Throw better errors for failing (not missing) plugins (#243) --- index.js | 5 ++++- test/error.js | 15 ++++++++++++++- test/fixtures/bad-plugin.js | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/bad-plugin.js diff --git a/index.js b/index.js index eed5d3e..9501e42 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,10 @@ const cliConfig = { try { return require(plugin)() } catch (e) { - return error(`Plugin Error: Cannot find module '${plugin}'`) + const msg = e.message || `Cannot find module '${plugin}'` + let prefix = msg.includes(plugin) ? '' : ` (${plugin})` + if (e.name && e.name !== 'Error') prefix += `: ${e.name}` + return error(`Plugin Error${prefix}: ${msg}'`) } }) : [] diff --git a/test/error.js b/test/error.js index b49781b..3d7732f 100644 --- a/test/error.js +++ b/test/error.js @@ -40,7 +40,7 @@ test.failing('invalid --config', t => { }) }) -test('PluginError', t => { +test('plugin not found', t => { return cli(['test/fixtures/a.css', '-u', 'postcss-plugin', '-o', tmp()]).then( ({ err, code }) => { t.is(code, 1, 'expected non-zero error code') @@ -52,6 +52,19 @@ test('PluginError', t => { ) }) +test('plugin throws on require', t => { + return cli([ + 'test/fixtures/a.css', + '-u', + './test/fixtures/bad-plugin', + '-o', + tmp() + ]).then(({ err, code }) => { + t.is(code, 1, 'expected non-zero error code') + t.regex(err.toString(), /Plugin Error \(.*bad-plugin\): This fails/) + }) +}) + test('CssSyntaxError', t => { return cli(['test/fixtures/a.css', '--parser', 'sugarss', '-o', tmp()]).then( ({ err, code }) => { diff --git a/test/fixtures/bad-plugin.js b/test/fixtures/bad-plugin.js new file mode 100644 index 0000000..2911e95 --- /dev/null +++ b/test/fixtures/bad-plugin.js @@ -0,0 +1 @@ +throw new Error('This fails') From f1f3056ea89584beab7e8e503b55c87670d7ae55 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 17 Oct 2018 21:16:05 -0400 Subject: [PATCH 080/251] Update nyc to v13.1.0 Closes #220 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17cdce6..68c7f89 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "coveralls": "^3.0.0", "eslint": "^5.0.0", "eslint-config-problems": "1.1.0", - "nyc": "^11.0.2", + "nyc": "^13.1.0", "postcss-import": "^12.0.0", "prettier": "~1.14.0", "sugarss": "^2.0.0", From 4db795fa7d56a3d3cf14703da92b9e0da4686473 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 17 Oct 2018 21:19:29 -0400 Subject: [PATCH 081/251] Clarify docs for --config flag Fixes #233 --- README.md | 2 +- lib/args.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5d0d4c3..372170c 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Advanced options: directory, for use with --dir [string] --poll Use polling for file watching. Can optionally pass polling interval; default 100 ms - --config Set a custom path to look for a config file [string] + --config Set a custom directory to look for a config file [string] Options: --version Show version number [boolean] diff --git a/lib/args.js b/lib/args.js index 7476023..1855260 100644 --- a/lib/args.js +++ b/lib/args.js @@ -118,7 +118,7 @@ Usage: implies: 'watch' }) .option('config', { - desc: 'Set a custom path to look for a config file', + desc: 'Set a custom directory to look for a config file', type: 'string' }) .version(version) From 46b7c10c59e4b3fa17f7a55f86f398d25861416d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 17 Oct 2018 21:26:58 -0400 Subject: [PATCH 082/251] 6.0.1 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b56b05e..a51e8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 6.0.1 / 2018-10-17 + +- Better error handling for errors thrown by plugins ([#242](https://github.com/postcss/postcss-cli/issues/242), [#243](https://github.com/postcss/postcss-cli/pull/243)) +- Update dependencies +- Clarify docs ([#233](https://github.com/postcss/postcss-cli/issues/233)) + # 6.0.0 / 2018-07-18 - Drop support for Node 4 diff --git a/package.json b/package.json index 68c7f89..463604c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "6.0.0", + "version": "6.0.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From b0112a6543d25d17ccadb142eb8bdeba8fcd4f54 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 7 Nov 2018 07:45:36 -0500 Subject: [PATCH 083/251] Update prettier to version 1.15.0 (#248) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 463604c..89e19a0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "1.1.0", "nyc": "^13.1.0", "postcss-import": "^12.0.0", - "prettier": "~1.14.0", + "prettier": "~1.15.0", "sugarss": "^2.0.0", "uuid": "^3.0.1" }, From 237325102ecde140849c40dc71827af5074be9ee Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 4 Dec 2018 20:03:45 -0500 Subject: [PATCH 084/251] Update eslint-config-problems to version 2.0.0 (#251) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89e19a0..4d3c23d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ava": "^0.25.0", "coveralls": "^3.0.0", "eslint": "^5.0.0", - "eslint-config-problems": "1.1.0", + "eslint-config-problems": "2.0.0", "nyc": "^13.1.0", "postcss-import": "^12.0.0", "prettier": "~1.15.0", From 488e4e799d1e2b8d45b860897a56e12fb4044a06 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 11 Dec 2018 19:07:48 -0500 Subject: [PATCH 085/251] Update dependency-graph to version 0.8.0 (#253) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d3c23d..a451ad1 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "chalk": "^2.1.0", "chokidar": "^2.0.0", - "dependency-graph": "^0.7.0", + "dependency-graph": "^0.8.0", "fs-extra": "^7.0.0", "get-stdin": "^6.0.0", "globby": "^8.0.0", From 54cdf3a932a23ff85b67b10b9fb7b014bbfb4230 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 15 Dec 2018 09:47:18 -0500 Subject: [PATCH 086/251] =?UTF-8?q?Update=20ava=20to=20the=20latest=20vers?= =?UTF-8?q?ion=20=F0=9F=9A=80=20(#255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(package): update ava to version 1.0.1 * t.ifError() -> t.falsy() --- package.json | 2 +- test/base.js | 2 +- test/cli.js | 2 +- test/config.js | 4 ++-- test/dir.js | 2 +- test/ext.js | 2 +- test/glob.js | 2 +- test/map.js | 6 +++--- test/misc.js | 4 ++-- test/parser.js | 2 +- test/replace.js | 2 +- test/stringifier.js | 2 +- test/syntax.js | 2 +- test/use.js | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index a451ad1..ac98dec 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "yargs": "^12.0.1" }, "devDependencies": { - "ava": "^0.25.0", + "ava": "^1.0.1", "coveralls": "^3.0.0", "eslint": "^5.0.0", "eslint-config-problems": "2.0.0", diff --git a/test/base.js b/test/base.js index aba6102..f0e67f6 100644 --- a/test/base.js +++ b/test/base.js @@ -17,7 +17,7 @@ test('--base --dir works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is( await read(path.join(dir, 'level-1/level-2/a.css')), diff --git a/test/cli.js b/test/cli.js index 87ed9f9..f41fb8b 100644 --- a/test/cli.js +++ b/test/cli.js @@ -14,7 +14,7 @@ test('works with defaults', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(output), await read('test/fixtures/a.css')) }) diff --git a/test/config.js b/test/config.js index f9d5c43..8900ae2 100644 --- a/test/config.js +++ b/test/config.js @@ -20,7 +20,7 @@ test('supports common config', async t => { dir ) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), @@ -38,7 +38,7 @@ test("doesn't error on empty config", async t => { dir ) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), diff --git a/test/dir.js b/test/dir.js index 8f31d35..5f35619 100644 --- a/test/dir.js +++ b/test/dir.js @@ -16,7 +16,7 @@ test('--dir works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(path.join(dir, 'a.css')), await read('test/fixtures/a.css')) diff --git a/test/ext.js b/test/ext.js index f24ada1..0748888 100644 --- a/test/ext.js +++ b/test/ext.js @@ -18,7 +18,7 @@ test('--ext works', async t => { '--ext', '.css' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) }) diff --git a/test/glob.js b/test/glob.js index 32da650..1cfd3c0 100644 --- a/test/glob.js +++ b/test/glob.js @@ -15,7 +15,7 @@ test('works with glob patterns', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is( await read(path.join(output, 'a.css')), diff --git a/test/map.js b/test/map.js index c82946a..53880d8 100644 --- a/test/map.js +++ b/test/map.js @@ -16,7 +16,7 @@ test('inline maps are generated by default', async t => { output ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.regex(await read(output), /\/*# sourceMappingURL=/) }) @@ -33,7 +33,7 @@ test('--map generates external sourcemaps', async t => { '--map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.truthy(await fs.pathExists(output.replace('.css', '.css.map'))) }) @@ -49,7 +49,7 @@ test('--no-map disables internal sourcemaps', async t => { output, '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.notRegex(await read(output), /\/*# sourceMappingURL=/) }) diff --git a/test/misc.js b/test/misc.js index 4689ceb..7887b36 100644 --- a/test/misc.js +++ b/test/misc.js @@ -5,7 +5,7 @@ import cli from './helpers/cli.js' test('--help', async t => { const help = await cli(['--help']) - t.ifError(help.error) + t.falsy(help.error) t.truthy(help.stdout.length > 10, 'expected --help to output a help message') }) @@ -13,7 +13,7 @@ test('--help', async t => { test('--version', async t => { const version = await cli(['--version']) - t.ifError(version.error) + t.falsy(version.error) t.truthy( version.stdout.length > 10, diff --git a/test/parser.js b/test/parser.js index 0febe22..1f7c0d2 100644 --- a/test/parser.js +++ b/test/parser.js @@ -16,7 +16,7 @@ test('--parser works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(output), await read('test/fixtures/s.css')) }) diff --git a/test/replace.js b/test/replace.js index ba2a15b..446749d 100644 --- a/test/replace.js +++ b/test/replace.js @@ -26,7 +26,7 @@ test('--replace works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(output), await read('test/fixtures/a.css')) }) diff --git a/test/stringifier.js b/test/stringifier.js index 4d7f8f8..caea774 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -16,7 +16,7 @@ test('--stringifier works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(output), await read('test/fixtures/a.sss')) }) diff --git a/test/syntax.js b/test/syntax.js index 39877d8..831a070 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -16,7 +16,7 @@ test('--syntax works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(output), await read('test/fixtures/a.sss')) }) diff --git a/test/use.js b/test/use.js index c6052e0..8171bad 100644 --- a/test/use.js +++ b/test/use.js @@ -16,7 +16,7 @@ test('--use works', async t => { '--no-map' ]) - t.ifError(error, stderr) + t.falsy(error, stderr) t.is(await read(output), await read('test/fixtures/a.css')) }) From 9ab9a2fbf7c6ec0c71bb95a73de8d34a3987811b Mon Sep 17 00:00:00 2001 From: Stefan Fisk Date: Wed, 19 Dec 2018 21:54:45 +0100 Subject: [PATCH 087/251] Only log warnings (#244) Currently messages are only logged if there are warnings, but if there are then all messages are logged. --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9501e42..86ce9f1 100644 --- a/index.js +++ b/index.js @@ -232,9 +232,13 @@ function css(css, file) { chalk`{green Finished {bold ${relativePath}} in {bold ${prettyTime}}}` ) - if (result.warnings().length) { - console.warn(reporter(result)) - } + console.warn( + reporter( + Object.assign({}, result, { + messages: result.warnings() + }) + ) + ) return result }) From ca69641cd26986a86b37fdd0eb446817f52d73bf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 19 Dec 2018 16:06:43 -0500 Subject: [PATCH 088/251] Fix prettier script; need to quote arguments --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac98dec..d6fb98f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "ci": "eslint . && nyc ava -v && npm run prettier -- --list-different", "clean": "node test/helpers/clean.js", - "prettier": "prettier --single-quote --no-semi **/*.{js,md}", + "prettier": "prettier --single-quote --no-semi \"**/*.{js,md}\"", "format": "npm run prettier -- --write && eslint . --fix", "pretest": "npm run clean && npm run format", "test": "nyc ava -v" From cd6014bb60f36b133c5160940255f4d96ef1ff58 Mon Sep 17 00:00:00 2001 From: Ryan Garant Date: Wed, 19 Dec 2018 16:06:10 -0800 Subject: [PATCH 089/251] Add --include-dotfiles option to allow glob to match files/dirs that begin with '.' (#254) --- README.md | 17 +++++++++-------- index.js | 5 ++++- lib/args.js | 4 ++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 372170c..b07b239 100644 --- a/README.md +++ b/README.md @@ -30,14 +30,15 @@ Usage: postcss ... [OPTIONS] --replace Basic options: - -o, --output Output file [string] - -d, --dir Output directory [string] - -r, --replace Replace (overwrite) the input file [boolean] - --map, -m Create an external sourcemap - --no-map Disable the default inline sourcemaps - --verbose Be verbose [boolean] - --watch, -w Watch files for changes and recompile as needed [boolean] - --env A shortcut for setting NODE_ENV [string] + -o, --output Output file [string] + -d, --dir Output directory [string] + -r, --replace Replace (overwrite) the input file [boolean] + --map, -m Create an external sourcemap + --no-map Disable the default inline sourcemaps + --verbose Be verbose [boolean] + --watch, -w Watch files for changes and recompile as needed [boolean] + --env A shortcut for setting NODE_ENV [string] + --include-dotfiles Enables glob to match files/dirs that begin with "." [boolean] Options for when not using a config file: -u, --use List of postcss plugins to use [array] diff --git a/index.js b/index.js index 86ce9f1..31ba4f4 100644 --- a/index.js +++ b/index.js @@ -53,7 +53,10 @@ Promise.resolve() if (argv.watch && !(argv.output || argv.replace || argv.dir)) { error('Cannot write to stdout in watch mode') } - if (input && input.length) return globber(input) + + if (input && input.length) { + return globber(input, { dot: argv.includeDotfiles }) + } if (argv.replace || argv.dir) { error( diff --git a/lib/args.js b/lib/args.js index 1855260..e85a211 100644 --- a/lib/args.js +++ b/lib/args.js @@ -58,6 +58,10 @@ Usage: type: 'boolean', conflicts: ['output', 'dir'] }) + .option('include-dotfiles', { + desc: 'Enables glob to match files/dirs that begin with "."', + type: 'boolean' + }) .alias('map', 'm') .describe('map', 'Create an external sourcemap') .describe('no-map', 'Disable the default inline sourcemaps') From afdc65f46757961a70439f6fb23d5d8c2f368056 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 19 Dec 2018 19:15:18 -0500 Subject: [PATCH 090/251] 6.1.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a51e8c1..441255a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 6.1.0 / 2018-12-19 + +- Add `--include-dotfiles` flag to allow globs to match dotfiles. ([#254](https://github.com/postcss/postcss-cli/pull/254)) +- Only log warning messages. This has always been intended behavior, but it wasn't working as expected. ([#244](https://github.com/postcss/postcss-cli/pull/244)) + # 6.0.1 / 2018-10-17 - Better error handling for errors thrown by plugins ([#242](https://github.com/postcss/postcss-cli/issues/242), [#243](https://github.com/postcss/postcss-cli/pull/243)) diff --git a/package.json b/package.json index d6fb98f..28dbdea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "6.0.1", + "version": "6.1.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 8c0a46548524e44e07fb10f3d6e2345f7b739231 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 4 Jan 2019 17:36:56 +0200 Subject: [PATCH 091/251] Check for messages length before logging. (#257) --- index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 31ba4f4..f96c07f 100644 --- a/index.js +++ b/index.js @@ -235,13 +235,16 @@ function css(css, file) { chalk`{green Finished {bold ${relativePath}} in {bold ${prettyTime}}}` ) - console.warn( - reporter( - Object.assign({}, result, { - messages: result.warnings() - }) + const messages = result.warnings() + if (messages.length) { + console.warn( + reporter( + Object.assign({}, result, { + messages + }) + ) ) - ) + } return result }) From f2aba4918ee9a0a8f0ffae886ab2326d1e6ad544 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 4 Jan 2019 10:46:21 -0500 Subject: [PATCH 092/251] 6.1.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 441255a..ed7df09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 6.1.1 / 2019-01-04 + +- Fix empty lines being printed in some cases ([#256](https://github.com/postcss/postcss-cli/issues/256), [#257](https://github.com/postcss/postcss-cli/pull/257)) + # 6.1.0 / 2018-12-19 - Add `--include-dotfiles` flag to allow globs to match dotfiles. ([#254](https://github.com/postcss/postcss-cli/pull/254)) diff --git a/package.json b/package.json index 28dbdea..9513816 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "6.1.0", + "version": "6.1.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 1301a31daa580a40a8df40cf62f7616f174dd7eb Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 15 Jan 2019 16:17:36 -0500 Subject: [PATCH 093/251] Fix test that still used removed -p option --- test/ext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ext.js b/test/ext.js index 0748888..1f06ed1 100644 --- a/test/ext.js +++ b/test/ext.js @@ -11,7 +11,7 @@ test('--ext works', async t => { const { error, stderr } = await cli([ 'test/fixtures/a.sss', - '-p', + '--parser', 'sugarss', '-d', dir, From 79e192bbb91ae35a8bea2646fbd95b1040e00cce Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 15 Jan 2019 16:20:46 -0500 Subject: [PATCH 094/251] Fix bug in tests err vs. error --- test/error.js | 28 ++++++++++++++-------------- test/helpers/cli.js | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/error.js b/test/error.js index 3d7732f..d0518c4 100644 --- a/test/error.js +++ b/test/error.js @@ -4,24 +4,24 @@ import tmp from './helpers/tmp.js' import cli from './helpers/cli.js' test('multiple input files && --output', t => { - return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ err, code }) => { + return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /Input Error: Must use --dir or --replace/) + t.regex(error.toString(), /Input Error: Must use --dir or --replace/) }) }) test('multiple input files && writing to stdout', t => { - return cli(['test/fixtures/*.css']).then(({ err, code }) => { + return cli(['test/fixtures/*.css']).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /Input Error: Must use --dir or --replace/) + t.regex(error.toString(), /Input Error: Must use --dir or --replace/) }) }) test('--map && writing to stdout', t => { - return cli(['test/fixtures/a.css', '--map']).then(({ err, code }) => { + return cli(['test/fixtures/a.css', '--map']).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex( - err.toString(), + error.toString(), /Output Error: Cannot output external sourcemaps when writing to STDOUT/ ) }) @@ -34,18 +34,18 @@ test.failing('invalid --config', t => { 'test/postcss.config.js', '-d', tmp() - ]).then(({ err, code }) => { + ]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /ENOENT: no such file or directory/) + t.regex(error.toString(), /ENOENT: no such file or directory/) }) }) test('plugin not found', t => { return cli(['test/fixtures/a.css', '-u', 'postcss-plugin', '-o', tmp()]).then( - ({ err, code }) => { + ({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex( - err.toString(), + error.toString(), /Plugin Error: Cannot find module 'postcss-plugin'/ ) } @@ -59,18 +59,18 @@ test('plugin throws on require', t => { './test/fixtures/bad-plugin', '-o', tmp() - ]).then(({ err, code }) => { + ]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(err.toString(), /Plugin Error \(.*bad-plugin\): This fails/) + t.regex(error.toString(), /Plugin Error \(.*bad-plugin\): This fails/) }) }) test('CssSyntaxError', t => { return cli(['test/fixtures/a.css', '--parser', 'sugarss', '-o', tmp()]).then( - ({ err, code }) => { + ({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex( - err.toString(), + error.toString(), /CssSyntaxError: .*a.css:1:4: Unnecessary curly bracket/ ) } diff --git a/test/helpers/cli.js b/test/helpers/cli.js index fef2086..4b939d4 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -6,10 +6,10 @@ export default function(args, cwd) { exec( `node ${path.resolve('bin/postcss')} ${args.join(' ')}`, { cwd }, - (err, stdout, stderr) => { + (error, stdout, stderr) => { resolve({ - code: err && err.code ? err.code : 0, - err, + code: error && error.code ? error.code : 0, + error, stdout, stderr }) From 938e1effedf2a314f5e72bb9e45210c4911aaebb Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 15 Jan 2019 16:25:12 -0500 Subject: [PATCH 095/251] Run watch tests locally, but not on CI --- test/watch.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/watch.js b/test/watch.js index b98fa6b..aa839f7 100644 --- a/test/watch.js +++ b/test/watch.js @@ -8,9 +8,10 @@ import chokidar from 'chokidar' import ENV from './helpers/env.js' import read from './helpers/read.js' -// XXX: All the tests in these files are skipped; the tests are too flaky on the CI +// XXX: All the tests in this file are skipped on the CI; too flacky there +const testCb = process.env.CI ? test.cb.skip : test.cb -test.cb.skip('--watch works', t => { +testCb('--watch works', t => { let cp t.plan(2) @@ -80,7 +81,7 @@ test.cb.skip('--watch works', t => { setTimeout(() => t.end('test timeout'), 50000) }) -test.cb.skip('--watch postcss.config.js', t => { +testCb('--watch postcss.config.js', t => { let cp t.plan(2) @@ -160,7 +161,7 @@ test.cb.skip('--watch postcss.config.js', t => { setTimeout(() => t.end('test timeout'), 50000) }) -test.cb.skip('--watch dependencies', t => { +testCb('--watch dependencies', t => { let cp t.plan(2) @@ -229,7 +230,7 @@ test.cb.skip('--watch dependencies', t => { setTimeout(() => t.end('test timeout'), 50000) }) -test.cb.skip("--watch doesn't exit on CssSyntaxError", t => { +testCb("--watch doesn't exit on CssSyntaxError", t => { t.plan(0) ENV('', ['a.css']) From c079cff295c5b2edc2fd66e413c4db88fd4bbea3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 15 Jan 2019 16:27:06 -0500 Subject: [PATCH 096/251] Test Node 10 & 11 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ca220d2..66bbf54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: false language: node_js node_js: - node + - 10 - 8 - 6 script: From 87a728658a137baac711e348e4b19d08f6374e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 22 Feb 2019 14:26:09 +0100 Subject: [PATCH 097/251] Update globby to v9.0.0 (#270) Fixes: https://github.com/postcss/postcss-cli/issues/265 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9513816..5d3754e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependency-graph": "^0.8.0", "fs-extra": "^7.0.0", "get-stdin": "^6.0.0", - "globby": "^8.0.0", + "globby": "^9.0.0", "postcss": "^7.0.0", "postcss-load-config": "^2.0.0", "postcss-reporter": "^6.0.0", From 72376fc9122493a9fbae479e379f5439440bc6eb Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 22 Feb 2019 08:31:25 -0500 Subject: [PATCH 098/251] Upgrade prettier to ~1.16.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d3754e..7d44b91 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "2.0.0", "nyc": "^13.1.0", "postcss-import": "^12.0.0", - "prettier": "~1.15.0", + "prettier": "~1.16.4", "sugarss": "^2.0.0", "uuid": "^3.0.1" }, From 8fd79b02a8445f2647605ac28ccc346bdf1cffed Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 22 Feb 2019 08:40:16 -0500 Subject: [PATCH 099/251] 6.1.2 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed7df09..5a22000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 6.1.2 / 2019-02-22 + +- Upgrade dependency globby to fix bug in sub-dependency ([#265](https://github.com/postcss/postcss-cli/issues/265), [#270](https://github.com/postcss/postcss-cli/pull/270)) + # 6.1.1 / 2019-01-04 - Fix empty lines being printed in some cases ([#256](https://github.com/postcss/postcss-cli/issues/256), [#257](https://github.com/postcss/postcss-cli/pull/257)) diff --git a/package.json b/package.json index 7d44b91..1ca2c78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "6.1.1", + "version": "6.1.2", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 541048ec2d7f32bb5f8eb338ecde74e3c4286d7c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 13 Apr 2019 13:35:13 -0400 Subject: [PATCH 100/251] Update prettier to version 1.17.0 (#272) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ca2c78..d510759 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "2.0.0", "nyc": "^13.1.0", "postcss-import": "^12.0.0", - "prettier": "~1.16.4", + "prettier": "~1.17.0", "sugarss": "^2.0.0", "uuid": "^3.0.1" }, From 035bab85c78fa34a9b3144c76b4d978c42abb9ec Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 16 Apr 2019 09:40:52 -0400 Subject: [PATCH 101/251] Update nyc to version 14.0.0 (#274) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d510759..7880637 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "coveralls": "^3.0.0", "eslint": "^5.0.0", "eslint-config-problems": "2.0.0", - "nyc": "^13.1.0", + "nyc": "^14.0.0", "postcss-import": "^12.0.0", "prettier": "~1.17.0", "sugarss": "^2.0.0", From f1c7352f2948c50f18abaa442af9d92dccce2f64 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 6 Jun 2019 20:47:06 -0400 Subject: [PATCH 102/251] Update prettier to version 1.18.0 (#281) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7880637..b5f82a3 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "2.0.0", "nyc": "^14.0.0", "postcss-import": "^12.0.0", - "prettier": "~1.17.0", + "prettier": "~1.18.0", "sugarss": "^2.0.0", "uuid": "^3.0.1" }, From 0de7ccf74d3f265af6a9224bb24c12038b8ac412 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 8 Jul 2019 18:46:47 +0200 Subject: [PATCH 103/251] Fix map file path creation (#286) * Add failing test for external map file path creation * Write passing map file implementation Can we just append + '.map'? * Add additional failing example * Simplify implementation --- index.js | 6 ++---- lib/getMapfile.js | 4 ++++ test/map.js | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 lib/getMapfile.js diff --git a/index.js b/index.js index f96c07f..8d79228 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ const reporter = require('postcss-reporter/lib/formatter')() const argv = require('./lib/args') const depGraph = require('./lib/depGraph') +const getMapfile = require('./lib/getMapfile') let input = argv._ const { dir, output } = argv @@ -221,10 +222,7 @@ function css(css, file) { tasks.push(fs.outputFile(options.to, result.css)) if (result.map) { - const mapfile = options.to.replace( - path.extname(options.to), - `${path.extname(options.to)}.map` - ) + const mapfile = getMapfile(options.to) tasks.push(fs.outputFile(mapfile, result.map)) } } else process.stdout.write(result.css, 'utf8') diff --git a/lib/getMapfile.js b/lib/getMapfile.js new file mode 100644 index 0000000..b9dd441 --- /dev/null +++ b/lib/getMapfile.js @@ -0,0 +1,4 @@ +'use strict' +module.exports = function getMapfile(p) { + return `${p}.map` +} diff --git a/test/map.js b/test/map.js index 53880d8..b944cd5 100644 --- a/test/map.js +++ b/test/map.js @@ -5,6 +5,8 @@ import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' import read from './helpers/read.js' +import getMapfile from '../lib/getMapfile' + test('inline maps are generated by default', async t => { const output = tmp('output.css') @@ -53,3 +55,24 @@ test('--no-map disables internal sourcemaps', async t => { t.notRegex(await read(output), /\/*# sourceMappingURL=/) }) + +test('mapFile path is property resolved', async t => { + const paths = [ + { + input: '/foo/bar.css/baz/index.css', + want: '/foo/bar.css/baz/index.css.map' + }, + { + input: '/foo/bar.sss/baz/index.sss', + want: '/foo/bar.sss/baz/index.sss.map' + }, + { + input: '/foo/bar.css/baz/bar.css', + want: '/foo/bar.css/baz/bar.css.map' + } + ] + + for (const p of paths) { + t.is(getMapfile(p.input), p.want) + } +}) From 709181958455e56e277340daa86d94d8cbe61b26 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 8 Jul 2019 12:53:42 -0400 Subject: [PATCH 104/251] 6.1.3 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a22000..1b71968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 6.1.3 / 2019-07-08 + +- Fix external sorcemap filenames when the directory name contains `.css` ([#283](https://github.com/postcss/postcss-cli/issues/283), [#286](https://github.com/postcss/postcss-cli/pull/286)) + # 6.1.2 / 2019-02-22 - Upgrade dependency globby to fix bug in sub-dependency ([#265](https://github.com/postcss/postcss-cli/issues/265), [#270](https://github.com/postcss/postcss-cli/pull/270)) diff --git a/package.json b/package.json index b5f82a3..756caf0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "6.1.2", + "version": "6.1.3", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 6b92df3bbc01ae73951d4f2884d71de295658409 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 30 Dec 2019 18:32:52 -0500 Subject: [PATCH 105/251] BREAKING: Drop Node 6 & 8; test on new Node versions --- .travis.yml | 3 +-- appveyor.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66bbf54..8cfe651 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,8 @@ sudo: false language: node_js node_js: - node + - 12 - 10 - - 8 - - 6 script: - npm run ci after_success: diff --git a/appveyor.yml b/appveyor.yml index e3e585d..c33b9fd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,7 @@ environment: matrix: + - nodejs_version: "12" - nodejs_version: "10" - - nodejs_version: "8" - - nodejs_version: "6" version: "{build}" build: off From 71384c6f2bc09f15a472ed329fbacbd858880a3f Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 30 Dec 2019 18:44:15 -0500 Subject: [PATCH 106/251] Update Travis config; remove AppVeyor --- .travis.yml | 6 ++++-- appveyor.yml | 17 ----------------- 2 files changed, 4 insertions(+), 19 deletions(-) delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index 8cfe651..6449c0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ -sudo: false language: node_js +os: + - linux + - windows node_js: - node - 12 @@ -7,4 +9,4 @@ node_js: script: - npm run ci after_success: -- './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' + - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c33b9fd..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -environment: - matrix: - - nodejs_version: "12" - - nodejs_version: "10" - -version: "{build}" -build: off -deploy: off - -install: - - ps: Install-Product node $env:nodejs_version - - npm install - -test_script: - - node --version - - npm --version - - npm run ci From 79eb0ac184309a4b53f52ca73e9eca94f1cc7cd9 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2019 18:54:44 -0500 Subject: [PATCH 107/251] Update get-stdin to version 7.0.0 (#273) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 756caf0..70a9d81 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "chokidar": "^2.0.0", "dependency-graph": "^0.8.0", "fs-extra": "^7.0.0", - "get-stdin": "^6.0.0", + "get-stdin": "^7.0.0", "globby": "^9.0.0", "postcss": "^7.0.0", "postcss-load-config": "^2.0.0", From 5c22ddb6856ee5596de602742873948918118564 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:01:32 -0500 Subject: [PATCH 108/251] Update yargs to version 15.0.2 (#298) Closes #269 Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70a9d81..146fb6f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "postcss-reporter": "^6.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "yargs": "^12.0.1" + "yargs": "^15.0.2" }, "devDependencies": { "ava": "^1.0.1", From 4f68a46bb793e3341247125ced2bd832ec28387e Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:15:02 -0500 Subject: [PATCH 109/251] Update chokidar to version 3.3.0 (#300) Closes #275 Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 146fb6f..f6eb090 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "chalk": "^2.1.0", - "chokidar": "^2.0.0", + "chokidar": "^3.3.0", "dependency-graph": "^0.8.0", "fs-extra": "^7.0.0", "get-stdin": "^7.0.0", From cb9f45161a1eb5d287ae1e029e3eae1d72fa0f5c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:15:10 -0500 Subject: [PATCH 110/251] Update fs-extra to version 8.1.0 (#301) Closes #278 Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f6eb090..e99bdc8 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "chalk": "^2.1.0", "chokidar": "^3.3.0", "dependency-graph": "^0.8.0", - "fs-extra": "^7.0.0", + "fs-extra": "^8.1.0", "get-stdin": "^7.0.0", "globby": "^9.0.0", "postcss": "^7.0.0", From 0d3591a45e73fc4a7e1cd804083d9a9c12f70339 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:31:15 -0500 Subject: [PATCH 111/251] Update ava to version 2.4.0 (#302) * chore(package): update ava to version 2.4.0 Closes #280 * Fix ava tests Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 9 +++++++-- test/error.js | 2 +- test/fixtures/{bad-plugin.js => _bad-plugin.js} | 0 3 files changed, 8 insertions(+), 3 deletions(-) rename test/fixtures/{bad-plugin.js => _bad-plugin.js} (100%) diff --git a/package.json b/package.json index e99bdc8..ac01aca 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "yargs": "^15.0.2" }, "devDependencies": { - "ava": "^1.0.1", + "ava": "^2.4.0", "coveralls": "^3.0.0", "eslint": "^5.0.0", "eslint-config-problems": "2.0.0", @@ -70,5 +70,10 @@ "url": "https://github.com/postcss/postcss-cli/issues" }, "homepage": "https://github.com/postcss/postcss-cli#readme", - "license": "MIT" + "license": "MIT", + "ava": { + "helpers": [ + "test/helpers/*" + ] + } } diff --git a/test/error.js b/test/error.js index d0518c4..cd26517 100644 --- a/test/error.js +++ b/test/error.js @@ -56,7 +56,7 @@ test('plugin throws on require', t => { return cli([ 'test/fixtures/a.css', '-u', - './test/fixtures/bad-plugin', + './test/fixtures/_bad-plugin', '-o', tmp() ]).then(({ error, code }) => { diff --git a/test/fixtures/bad-plugin.js b/test/fixtures/_bad-plugin.js similarity index 100% rename from test/fixtures/bad-plugin.js rename to test/fixtures/_bad-plugin.js From e66650579b13b19704c31f13b2efe179db6037ca Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:39:39 -0500 Subject: [PATCH 112/251] Update prettier to version 1.19.1 (#304) * chore(package): update prettier to version 1.19.1 Closes #293 * Format code Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- test/watch.js | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index ac01aca..8218521 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "2.0.0", "nyc": "^14.0.0", "postcss-import": "^12.0.0", - "prettier": "~1.18.0", + "prettier": "~1.19.1", "sugarss": "^2.0.0", "uuid": "^3.0.1" }, diff --git a/test/watch.js b/test/watch.js index aa839f7..255fb6b 100644 --- a/test/watch.js +++ b/test/watch.js @@ -62,9 +62,10 @@ testCb('--watch works', t => { // Helper functions: function isEqual(p, expected) { - return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) - ) + return Promise.all([ + read(path.join(dir, p)), + read(expected) + ]).then(([a, e]) => t.is(a, e)) } function done(err) { @@ -142,9 +143,10 @@ testCb('--watch postcss.config.js', t => { // Helper functions: function isEqual(p, expected) { - return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) - ) + return Promise.all([ + read(path.join(dir, p)), + read(expected) + ]).then(([a, e]) => t.is(a, e)) } function done(err) { @@ -212,9 +214,10 @@ testCb('--watch dependencies', t => { // Helper functions: function isEqual(p, expected) { - return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) - ) + return Promise.all([ + read(path.join(dir, p)), + read(expected) + ]).then(([a, e]) => t.is(a, e)) } function done(err) { From 4a87ff162ec3cb5793bbc0533726a321cd9be037 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:44:41 -0500 Subject: [PATCH 113/251] Update chalk to version 3.0.0 (#294) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8218521..ac30b64 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test": "nyc ava -v" }, "dependencies": { - "chalk": "^2.1.0", + "chalk": "^3.0.0", "chokidar": "^3.3.0", "dependency-graph": "^0.8.0", "fs-extra": "^8.1.0", From e241672a16374a65c5d9e591f92a8843cef2f0fb Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2019 19:49:49 -0500 Subject: [PATCH 114/251] Update nyc to version 15.0.0 (#297) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac30b64..3009882 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "coveralls": "^3.0.0", "eslint": "^5.0.0", "eslint-config-problems": "2.0.0", - "nyc": "^14.0.0", + "nyc": "^15.0.0", "postcss-import": "^12.0.0", "prettier": "~1.19.1", "sugarss": "^2.0.0", From 5b47456fe90905fe3d524faee92200550a7ee3b3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 30 Dec 2019 20:09:45 -0500 Subject: [PATCH 115/251] Update eslint to version 6.8.0 (#305) Closes #282 Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3009882..b466a52 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "devDependencies": { "ava": "^2.4.0", "coveralls": "^3.0.0", - "eslint": "^5.0.0", + "eslint": "^6.8.0", "eslint-config-problems": "2.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", From 151943012d8dea815488a238eb51fb260bf510c0 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Tue, 7 Jan 2020 11:12:57 -0500 Subject: [PATCH 116/251] Update globby to version 10.0.1 (#303) Closes #284 Fix Windows file handling Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- test/replace.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b466a52..382be78 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependency-graph": "^0.8.0", "fs-extra": "^8.1.0", "get-stdin": "^7.0.0", - "globby": "^9.0.0", + "globby": "^10.0.1", "postcss": "^7.0.0", "postcss-load-config": "^2.0.0", "postcss-reporter": "^6.0.0", diff --git a/test/replace.js b/test/replace.js index 446749d..2f99f3b 100644 --- a/test/replace.js +++ b/test/replace.js @@ -17,9 +17,8 @@ test('--replace works', async t => { fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')) ]) - // XXX: Should be able to pass output instead of dir here, but this test env is weird const { error, stderr } = await cli([ - dir, + output.replace(/\\/g, '/'), // gotta keep globby happy on Windows '--replace', '-u', 'postcss-import', From ea1cec400e4e0112690454349d7846c6908e4959 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Tue, 7 Jan 2020 11:16:46 -0500 Subject: [PATCH 117/251] Update eslint-config-problems to version 3.1.0 (#306) Closes #279 Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 382be78..01fc8be 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ava": "^2.4.0", "coveralls": "^3.0.0", "eslint": "^6.8.0", - "eslint-config-problems": "2.0.0", + "eslint-config-problems": "3.1.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", "prettier": "~1.19.1", From cf6ea0991343e05e3fd101c2fd16f6b537f6cb35 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 7 Jan 2020 11:18:35 -0500 Subject: [PATCH 118/251] Update eslint config --- .eslintrc.yaml | 2 +- index.js | 10 ++-------- test/.eslintrc.yaml | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0473b0f..2af7adc 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,5 +1,5 @@ env: node: true -extends: problems +extends: problems/node10 rules: no-console: off diff --git a/index.js b/index.js index 8d79228..e54247d 100644 --- a/index.js +++ b/index.js @@ -187,7 +187,7 @@ function css(css, file) { return rc(ctx, argv.config) .then(config => { config = config || cliConfig - const options = Object.assign({}, config.options) + const options = { ...config.options } if (file === 'stdin' && output) file = output @@ -235,13 +235,7 @@ function css(css, file) { const messages = result.warnings() if (messages.length) { - console.warn( - reporter( - Object.assign({}, result, { - messages - }) - ) - ) + console.warn(reporter({ ...result, messages })) } return result diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 066cdcd..add5a78 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -1,3 +1,2 @@ parserOptions: - ecmaVersion: 2017 sourceType: module From 745ad2cedec4b8b9fc793f3748d72ce03c5d2f9e Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 7 Jan 2020 11:28:26 -0500 Subject: [PATCH 119/251] 7.0.0 --- CHANGELOG.md | 6 ++++++ package.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b71968..37304d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 7.0.0 / 2020-01-07 + +- **BREAKING:** Drop support for Node 6 & 8 +- Update `globby`, which may be a breaking change for a small number of users using certain glob patterns, see https://github.com/mrmlnc/fast-glob#pattern-syntax for details ([#303](https://github.com/postcss/postcss-cli/pull/303)) +- Update dependencies + # 6.1.3 / 2019-07-08 - Fix external sorcemap filenames when the directory name contains `.css` ([#283](https://github.com/postcss/postcss-cli/issues/283), [#286](https://github.com/postcss/postcss-cli/pull/286)) diff --git a/package.json b/package.json index 01fc8be..a14d012 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "postcss-cli", - "version": "6.1.3", + "version": "7.0.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { - "node": ">=6" + "node": ">=10" }, "bin": { "postcss": "./bin/postcss" From 568528de1a53c77a5928b4ad87bbf877c25692da Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Thu, 9 Jan 2020 13:24:22 +0000 Subject: [PATCH 120/251] Respect map.annotation string (#307) * fix: respect map.annotation string * test: fix unit tests for getMapFile * fix: always use posix paths in getMapFile * style: prettier lib/getMapFile --- index.js | 2 +- lib/getMapfile.js | 8 ++++++-- test/map.js | 10 +++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index e54247d..0e4bef8 100644 --- a/index.js +++ b/index.js @@ -222,7 +222,7 @@ function css(css, file) { tasks.push(fs.outputFile(options.to, result.css)) if (result.map) { - const mapfile = getMapfile(options.to) + const mapfile = getMapfile(options) tasks.push(fs.outputFile(mapfile, result.map)) } } else process.stdout.write(result.css, 'utf8') diff --git a/lib/getMapfile.js b/lib/getMapfile.js index b9dd441..346fea7 100644 --- a/lib/getMapfile.js +++ b/lib/getMapfile.js @@ -1,4 +1,8 @@ 'use strict' -module.exports = function getMapfile(p) { - return `${p}.map` +const path = require('path') +module.exports = function getMapfile(options) { + if (options.map && typeof options.map.annotation === 'string') { + return `${path.dirname(options.to)}/${options.map.annotation}` + } + return `${options.to}.map` } diff --git a/test/map.js b/test/map.js index b944cd5..7c3c2ba 100644 --- a/test/map.js +++ b/test/map.js @@ -59,16 +59,20 @@ test('--no-map disables internal sourcemaps', async t => { test('mapFile path is property resolved', async t => { const paths = [ { - input: '/foo/bar.css/baz/index.css', + input: { to: '/foo/bar.css/baz/index.css' }, want: '/foo/bar.css/baz/index.css.map' }, { - input: '/foo/bar.sss/baz/index.sss', + input: { to: '/foo/bar.sss/baz/index.sss' }, want: '/foo/bar.sss/baz/index.sss.map' }, { - input: '/foo/bar.css/baz/bar.css', + input: { to: '/foo/bar.css/baz/bar.css' }, want: '/foo/bar.css/baz/bar.css.map' + }, + { + input: { map: { annotation: 'foo.map' }, to: '/foo/bar.css/baz/bar.css' }, + want: '/foo/bar.css/baz/foo.map' } ] From 9fb5dbe9b6be4b881a6fa3157b28a4645050f36f Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 9 Jan 2020 08:27:28 -0500 Subject: [PATCH 121/251] 7.1.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37304d3..87e24e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 7.1.0 / 2020-01-09 + +- Respect `map.annotation` option when set to a string ([#307](https://github.com/postcss/postcss-cli/pull/307)) + # 7.0.0 / 2020-01-07 - **BREAKING:** Drop support for Node 6 & 8 diff --git a/package.json b/package.json index a14d012..2a71aa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "7.0.0", + "version": "7.1.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 6b0666e436ec82fba9710192c53df3a106c6bfbf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Wed, 29 Jan 2020 20:09:32 -0500 Subject: [PATCH 122/251] Update ava to version 3.1.0 (#309) * chore(package): update ava to version 3.1.0 Closes #308 * Remove ava helpers option * Remove import/export usage in tests; since ava no longer includes Babel Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 9 ++------- test/base.js | 10 +++++----- test/cli.js | 8 ++++---- test/config.js | 10 +++++----- test/dir.js | 10 +++++----- test/error.js | 6 +++--- test/ext.js | 10 +++++----- test/glob.js | 10 +++++----- test/helpers/cli.js | 6 +++--- test/helpers/env.js | 10 +++++----- test/helpers/read.js | 4 ++-- test/helpers/tmp.js | 6 +++--- test/map.js | 12 ++++++------ test/misc.js | 4 ++-- test/parser.js | 8 ++++---- test/replace.js | 12 ++++++------ test/stdin.js | 12 ++++++------ test/stdout.js | 10 +++++----- test/stringifier.js | 8 ++++---- test/syntax.js | 8 ++++---- test/use.js | 8 ++++---- test/watch.js | 14 +++++++------- 22 files changed, 95 insertions(+), 100 deletions(-) diff --git a/package.json b/package.json index 2a71aa9..8d20717 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "yargs": "^15.0.2" }, "devDependencies": { - "ava": "^2.4.0", + "ava": "^3.1.0", "coveralls": "^3.0.0", "eslint": "^6.8.0", "eslint-config-problems": "3.1.0", @@ -70,10 +70,5 @@ "url": "https://github.com/postcss/postcss-cli/issues" }, "homepage": "https://github.com/postcss/postcss-cli#readme", - "license": "MIT", - "ava": { - "helpers": [ - "test/helpers/*" - ] - } + "license": "MIT" } diff --git a/test/base.js b/test/base.js index f0e67f6..2a7d383 100644 --- a/test/base.js +++ b/test/base.js @@ -1,9 +1,9 @@ -import test from 'ava' -import path from 'path' +const test = require('ava') +const path = require('path') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--base --dir works', async t => { const dir = tmp() diff --git a/test/cli.js b/test/cli.js index f41fb8b..8cde5dc 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,8 +1,8 @@ -import test from 'ava' +const test = require('ava') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('works with defaults', async t => { const output = tmp('output.css') diff --git a/test/config.js b/test/config.js index 8900ae2..e654452 100644 --- a/test/config.js +++ b/test/config.js @@ -1,10 +1,10 @@ -import test from 'ava' -import path from 'path' +const test = require('ava') +const path = require('path') -import ENV from './helpers/env.js' +const ENV = require('./helpers/env.js') -import cli from './helpers/cli.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const read = require('./helpers/read.js') test('supports common config', async t => { const env = `module.exports = { diff --git a/test/dir.js b/test/dir.js index 5f35619..19dd22a 100644 --- a/test/dir.js +++ b/test/dir.js @@ -1,9 +1,9 @@ -import test from 'ava' -import path from 'path' +const test = require('ava') +const path = require('path') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--dir works', async t => { const dir = tmp() diff --git a/test/error.js b/test/error.js index cd26517..1a48b47 100644 --- a/test/error.js +++ b/test/error.js @@ -1,7 +1,7 @@ -import test from 'ava' +const test = require('ava') -import tmp from './helpers/tmp.js' -import cli from './helpers/cli.js' +const tmp = require('./helpers/tmp.js') +const cli = require('./helpers/cli.js') test('multiple input files && --output', t => { return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ error, code }) => { diff --git a/test/ext.js b/test/ext.js index 1f06ed1..4edcda9 100644 --- a/test/ext.js +++ b/test/ext.js @@ -1,10 +1,10 @@ -import test from 'ava' +const test = require('ava') -import fs from 'fs-extra' -import path from 'path' +const fs = require('fs-extra') +const path = require('path') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') test('--ext works', async t => { const dir = tmp() diff --git a/test/glob.js b/test/glob.js index 1cfd3c0..2ad919b 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,9 +1,9 @@ -import test from 'ava' -import path from 'path' +const test = require('ava') +const path = require('path') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('works with glob patterns', async t => { const output = tmp() diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 4b939d4..1d44f11 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,7 +1,7 @@ -import path from 'path' -import { exec } from 'child_process' +const path = require('path') +const { exec } = require('child_process') -export default function(args, cwd) { +module.exports = function(args, cwd) { return new Promise(resolve => { exec( `node ${path.resolve('bin/postcss')} ${args.join(' ')}`, diff --git a/test/helpers/env.js b/test/helpers/env.js index 32c78f8..dfafef8 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,10 +1,10 @@ -import fs from 'fs-extra' -import path from 'path' -import globby from 'globby' +const fs = require('fs-extra') +const path = require('path') +const globby = require('globby') -import tmp from './tmp.js' +const tmp = require('./tmp.js') -export default function(config, fixtures) { +module.exports = function(config, fixtures) { fixtures = fixtures || '**/*' const dir = tmp() diff --git a/test/helpers/read.js b/test/helpers/read.js index ead014d..67de968 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,5 +1,5 @@ -import { readFile } from 'fs-extra' +const { readFile } = require('fs-extra') -export default function(path) { +module.exports = function(path) { return readFile(path, 'utf8').then(content => content.replace(/\r\n/g, '\n')) // normalize line endings on Windows } diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index d05dec9..0ae40e5 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,7 +1,7 @@ -import path from 'path' -import uuid from 'uuid' +const path = require('path') +const uuid = require('uuid') -export default function(ext) { +module.exports = function(ext) { ext = ext || '' return path.join('test/fixtures/.tmp', uuid(), ext) diff --git a/test/map.js b/test/map.js index 7c3c2ba..1497c61 100644 --- a/test/map.js +++ b/test/map.js @@ -1,11 +1,11 @@ -import test from 'ava' -import fs from 'fs-extra' +const test = require('ava') +const fs = require('fs-extra') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') -import getMapfile from '../lib/getMapfile' +const getMapfile = require('../lib/getMapfile') test('inline maps are generated by default', async t => { const output = tmp('output.css') diff --git a/test/misc.js b/test/misc.js index 7887b36..b9b7415 100644 --- a/test/misc.js +++ b/test/misc.js @@ -1,6 +1,6 @@ -import test from 'ava' +const test = require('ava') -import cli from './helpers/cli.js' +const cli = require('./helpers/cli.js') test('--help', async t => { const help = await cli(['--help']) diff --git a/test/parser.js b/test/parser.js index 1f7c0d2..7e6ab5c 100644 --- a/test/parser.js +++ b/test/parser.js @@ -1,8 +1,8 @@ -import test from 'ava' +const test = require('ava') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--parser works', async t => { const output = tmp('output.css') diff --git a/test/replace.js b/test/replace.js index 2f99f3b..51cfe96 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,11 +1,11 @@ -import test from 'ava' +const test = require('ava') -import fs from 'fs-extra' -import path from 'path' +const fs = require('fs-extra') +const path = require('path') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--replace works', async t => { const dir = tmp() diff --git a/test/stdin.js b/test/stdin.js index 86e15bf..695f5e6 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -1,11 +1,11 @@ -import test from 'ava' +const test = require('ava') -import fs from 'fs-extra' -import path from 'path' -import { exec } from 'child_process' +const fs = require('fs-extra') +const path = require('path') +const { exec } = require('child_process') -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test.cb('reads from stdin', t => { const output = tmp('output.css') diff --git a/test/stdout.js b/test/stdout.js index da1401a..4ea43c4 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -1,10 +1,10 @@ -import test from 'ava' +const test = require('ava') -import fs from 'fs-extra' -import path from 'path' -import { exec } from 'child_process' +const fs = require('fs-extra') +const path = require('path') +const { exec } = require('child_process') -import read from './helpers/read.js' +const read = require('./helpers/read.js') test.cb('writes to stdout', t => { const cp = exec( diff --git a/test/stringifier.js b/test/stringifier.js index caea774..beb5e70 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -1,8 +1,8 @@ -import test from 'ava' +const test = require('ava') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--stringifier works', async t => { const output = tmp('output.sss') diff --git a/test/syntax.js b/test/syntax.js index 831a070..a4a42c8 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -1,8 +1,8 @@ -import test from 'ava' +const test = require('ava') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--syntax works', async t => { const output = tmp('output.sss') diff --git a/test/use.js b/test/use.js index 8171bad..f53650f 100644 --- a/test/use.js +++ b/test/use.js @@ -1,8 +1,8 @@ -import test from 'ava' +const test = require('ava') -import cli from './helpers/cli.js' -import tmp from './helpers/tmp.js' -import read from './helpers/read.js' +const cli = require('./helpers/cli.js') +const tmp = require('./helpers/tmp.js') +const read = require('./helpers/read.js') test('--use works', async t => { const output = tmp('i.css') diff --git a/test/watch.js b/test/watch.js index 255fb6b..d80baa0 100644 --- a/test/watch.js +++ b/test/watch.js @@ -1,12 +1,12 @@ -import test from 'ava' +const test = require('ava') -import fs from 'fs-extra' -import path from 'path' -import { exec } from 'child_process' -import chokidar from 'chokidar' +const fs = require('fs-extra') +const path = require('path') +const { exec } = require('child_process') +const chokidar = require('chokidar') -import ENV from './helpers/env.js' -import read from './helpers/read.js' +const ENV = require('./helpers/env.js') +const read = require('./helpers/read.js') // XXX: All the tests in this file are skipped on the CI; too flacky there const testCb = process.env.CI ? test.cb.skip : test.cb From 459cc48fc5a676c8a7f838433bf1f4120c395ef7 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2020 21:21:35 -0500 Subject: [PATCH 123/251] =?UTF-8?q?Update=20eslint-config-problems=20to=20?= =?UTF-8?q?the=20latest=20version=20=F0=9F=9A=80=20(#310)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(package): update eslint-config-problems to version 4.0.0 * Use base config * Use optional catch bindings Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> --- .eslintrc.yaml | 2 +- package.json | 2 +- test/watch.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 2af7adc..0473b0f 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,5 +1,5 @@ env: node: true -extends: problems/node10 +extends: problems rules: no-console: off diff --git a/package.json b/package.json index 8d20717..10bf98c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ava": "^3.1.0", "coveralls": "^3.0.0", "eslint": "^6.8.0", - "eslint-config-problems": "3.1.0", + "eslint-config-problems": "4.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", "prettier": "~1.19.1", diff --git a/test/watch.js b/test/watch.js index d80baa0..993c873 100644 --- a/test/watch.js +++ b/test/watch.js @@ -71,7 +71,7 @@ testCb('--watch works', t => { function done(err) { try { cp.kill() - } catch (e) {} + } catch {} t.end(err) } @@ -152,7 +152,7 @@ testCb('--watch postcss.config.js', t => { function done(err) { try { cp.kill() - } catch (e) {} + } catch {} t.end(err) } @@ -223,7 +223,7 @@ testCb('--watch dependencies', t => { function done(err) { try { cp.kill() - } catch (e) {} + } catch {} t.end(err) } }) @@ -274,7 +274,7 @@ testCb("--watch doesn't exit on CssSyntaxError", t => { function done(err) { try { cp.kill() - } catch (e) {} + } catch {} t.end(err) } From e6828a9e5f5bc42be074894e3a2bc7f1b725474b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2020 09:30:32 -0500 Subject: [PATCH 124/251] Update dependency-graph to version 0.9.0 (#311) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10bf98c..661f7b3 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "chalk": "^3.0.0", "chokidar": "^3.3.0", - "dependency-graph": "^0.8.0", + "dependency-graph": "^0.9.0", "fs-extra": "^8.1.0", "get-stdin": "^7.0.0", "globby": "^10.0.1", From 62ac6a48b1453f84d42f3819b46436f1b0c9df68 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2020 12:19:58 -0400 Subject: [PATCH 125/251] Update fs-extra to version 9.0.0 (#315) Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 661f7b3..ba6688e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "chalk": "^3.0.0", "chokidar": "^3.3.0", "dependency-graph": "^0.9.0", - "fs-extra": "^8.1.0", + "fs-extra": "^9.0.0", "get-stdin": "^7.0.0", "globby": "^10.0.1", "postcss": "^7.0.0", From 75746384796f3da2f1958471cf9e15fdd0c3049b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2020 10:04:53 -0400 Subject: [PATCH 126/251] Configure Renovate (#316) * Add renovate.json * Update config Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- renovate.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..a513283 --- /dev/null +++ b/renovate.json @@ -0,0 +1,7 @@ +{ + "extends": [ + "config:base", + ":preserveSemverRanges", + ":label(deps)" + ] +} From 42fc85e743b20dd8d4f3d6a1d16b4de31f7aa08a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2020 10:52:13 -0400 Subject: [PATCH 127/251] Update dependency globby to v11 (#317) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba6688e..fc09f41 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependency-graph": "^0.9.0", "fs-extra": "^9.0.0", "get-stdin": "^7.0.0", - "globby": "^10.0.1", + "globby": "^11.0.0", "postcss": "^7.0.0", "postcss-load-config": "^2.0.0", "postcss-reporter": "^6.0.0", From 96699c10786a5938249a38a9d745a8633e1934c8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2020 09:45:47 -0400 Subject: [PATCH 128/251] Update dependency prettier to v2 (#319) * Update dependency prettier to v2 * Update files * Fix autocrlf Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- .travis.yml | 2 ++ README.md | 16 ++++++------ index.js | 48 +++++++++++++++++----------------- lib/args.js | 30 +++++++++++----------- lib/depGraph.js | 4 +-- package.json | 2 +- test/base.js | 4 +-- test/cli.js | 4 +-- test/config.js | 8 +++--- test/dir.js | 4 +-- test/error.js | 18 ++++++------- test/ext.js | 4 +-- test/glob.js | 4 +-- test/helpers/clean.js | 4 +-- test/helpers/cli.js | 6 ++--- test/helpers/env.js | 8 +++--- test/helpers/read.js | 6 +++-- test/helpers/tmp.js | 2 +- test/map.js | 24 ++++++++--------- test/misc.js | 4 +-- test/parser.js | 4 +-- test/replace.js | 6 ++--- test/stdin.js | 2 +- test/stdout.js | 2 +- test/stringifier.js | 4 +-- test/syntax.js | 4 +-- test/use.js | 4 +-- test/watch.js | 60 +++++++++++++++++++++---------------------- 28 files changed, 146 insertions(+), 142 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6449c0b..410129e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: node_js +git: + autocrlf: input os: - linux - windows diff --git a/README.md b/README.md index b07b239..4eeb62a 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,8 @@ module.exports = { parser: 'sugarss', plugins: [ require('postcss-import')({ ...options }), - require('postcss-url')({ url: 'copy', useHash: true }) - ] + require('postcss-url')({ url: 'copy', useHash: true }), + ], } ``` @@ -105,13 +105,13 @@ For more advanced usage it's recommend to to use a function in `postcss.config.j **postcss.config.js** ```js -module.exports = ctx => ({ +module.exports = (ctx) => ({ map: ctx.options.map, parser: ctx.file.extname === '.sss' ? 'sugarss' : false, plugins: { 'postcss-import': { root: ctx.file.dirname }, - cssnano: ctx.env === 'production' ? {} : false - } + cssnano: ctx.env === 'production' ? {} : false, + }, }) ``` @@ -124,13 +124,13 @@ postcss input.sss -p sugarss -o output.css -m **postcss.config.js** ```js -module.exports = ctx => ({ +module.exports = (ctx) => ({ map: ctx.options.map, parser: ctx.options.parser, plugins: { 'postcss-import': { root: ctx.file.dirname }, - cssnano: ctx.env === 'production' ? {} : false - } + cssnano: ctx.env === 'production' ? {} : false, + }, }) ``` diff --git a/index.js b/index.js index 0e4bef8..92358b7 100644 --- a/index.js +++ b/index.js @@ -28,10 +28,10 @@ const cliConfig = { map: argv.map !== undefined ? argv.map : { inline: true }, parser: argv.parser ? require(argv.parser) : undefined, syntax: argv.syntax ? require(argv.syntax) : undefined, - stringifier: argv.stringifier ? require(argv.stringifier) : undefined + stringifier: argv.stringifier ? require(argv.stringifier) : undefined, }, plugins: argv.use - ? argv.use.map(plugin => { + ? argv.use.map((plugin) => { try { return require(plugin)() } catch (e) { @@ -41,7 +41,7 @@ const cliConfig = { return error(`Plugin Error${prefix}: ${msg}'`) } }) - : [] + : [], } let configFile @@ -71,7 +71,7 @@ Promise.resolve() return ['stdin'] }) - .then(i => { + .then((i) => { if (!i || !i.length) { error('Input Error: You must pass a valid list of files to parse') } @@ -82,13 +82,13 @@ Promise.resolve() ) } - if (i[0] !== 'stdin') i = i.map(i => path.resolve(i)) + if (i[0] !== 'stdin') i = i.map((i) => path.resolve(i)) input = i return files(input) }) - .then(results => { + .then((results) => { if (argv.watch) { const printMessage = () => printVerbose(chalk.dim('\nWaiting for file changes...')) @@ -97,31 +97,31 @@ Promise.resolve() interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100, awaitWriteFinish: { stabilityThreshold: 50, - pollInterval: 10 - } + pollInterval: 10, + }, }) if (configFile) watcher.add(configFile) - watcher.on('ready', printMessage).on('change', file => { + watcher.on('ready', printMessage).on('change', (file) => { let recompile = [] if (input.includes(file)) recompile.push(file) recompile = recompile.concat( - depGraph.dependantsOf(file).filter(file => input.includes(file)) + depGraph.dependantsOf(file).filter((file) => input.includes(file)) ) if (!recompile.length) recompile = input return files(recompile) - .then(results => watcher.add(dependencies(results))) + .then((results) => watcher.add(dependencies(results))) .then(printMessage) .catch(error) }) } }) - .catch(err => { + .catch((err) => { error(err) process.exit(1) @@ -131,7 +131,7 @@ function rc(ctx, path) { if (argv.use) return Promise.resolve(cliConfig) return postcssrc(ctx, path) - .then(rc => { + .then((rc) => { if (rc.options.from || rc.options.to) { error( 'Config Error: Can not set from or to options in config file, use CLI arguments instead' @@ -140,7 +140,7 @@ function rc(ctx, path) { configFile = rc.file return rc }) - .catch(err => { + .catch((err) => { if (!err.message.includes('No PostCSS Config found')) throw err }) } @@ -149,15 +149,15 @@ function files(files) { if (typeof files === 'string') files = [files] return Promise.all( - files.map(file => { + files.map((file) => { if (file === 'stdin') { - return stdin().then(content => { + return stdin().then((content) => { if (!content) return error('Input Error: Did not receive any STDIN') return css(content, 'stdin') }) } - return read(file).then(content => css(content, file)) + return read(file).then((content) => css(content, file)) }) ) } @@ -169,7 +169,7 @@ function css(css, file) { ctx.file = { dirname: path.dirname(file), basename: path.basename(file), - extname: path.extname(file) + extname: path.extname(file), } if (!argv.config) argv.config = path.dirname(file) @@ -185,7 +185,7 @@ function css(css, file) { printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`) return rc(ctx, argv.config) - .then(config => { + .then((config) => { config = config || cliConfig const options = { ...config.options } @@ -215,7 +215,7 @@ function css(css, file) { return postcss(config.plugins) .process(css, options) - .then(result => { + .then((result) => { const tasks = [] if (options.to) { @@ -242,7 +242,7 @@ function css(css, file) { }) }) }) - .catch(err => { + .catch((err) => { throw err }) } @@ -252,13 +252,13 @@ function dependencies(results) { const messages = [] - results.forEach(result => { + results.forEach((result) => { if (result.messages <= 0) return result.messages - .filter(msg => (msg.type === 'dependency' ? msg : '')) + .filter((msg) => (msg.type === 'dependency' ? msg : '')) .map(depGraph.add) - .forEach(dependency => messages.push(dependency.file)) + .forEach((dependency) => messages.push(dependency.file)) }) return messages diff --git a/lib/args.js b/lib/args.js index e85a211..9172a93 100644 --- a/lib/args.js +++ b/lib/args.js @@ -44,40 +44,40 @@ Usage: alias: 'output', desc: 'Output file', type: 'string', - conflicts: ['dir', 'replace'] + conflicts: ['dir', 'replace'], }) .option('d', { alias: 'dir', desc: 'Output directory', type: 'string', - conflicts: ['output', 'replace'] + conflicts: ['output', 'replace'], }) .option('r', { alias: 'replace', desc: 'Replace (overwrite) the input file', type: 'boolean', - conflicts: ['output', 'dir'] + conflicts: ['output', 'dir'], }) .option('include-dotfiles', { desc: 'Enables glob to match files/dirs that begin with "."', - type: 'boolean' + type: 'boolean', }) .alias('map', 'm') .describe('map', 'Create an external sourcemap') .describe('no-map', 'Disable the default inline sourcemaps') .option('verbose', { desc: 'Be verbose', - type: 'boolean' + type: 'boolean', }) .option('watch', { alias: 'w', desc: 'Watch files for changes and recompile as needed', type: 'boolean', - conflicts: 'replace' + conflicts: 'replace', }) .option('env', { desc: 'A shortcut for setting NODE_ENV', - type: 'string' + type: 'string', }) .group( ['u', 'parser', 'stringifier', 'syntax'], @@ -86,19 +86,19 @@ Usage: .option('u', { alias: 'use', desc: 'List of postcss plugins to use', - type: 'array' + type: 'array', }) .option('parser', { desc: 'Custom postcss parser', - type: 'string' + type: 'string', }) .option('stringifier', { desc: 'Custom postcss stringifier', - type: 'string' + type: 'string', }) .option('syntax', { desc: 'Custom postcss syntax', - type: 'string' + type: 'string', }) .group(['ext', 'base', 'poll', 'config'], 'Advanced options:') .option('ext', { @@ -108,22 +108,22 @@ Usage: coerce(ext) { if (ext.indexOf('.') !== 0) return `.${ext}` return ext - } + }, }) .option('base', { desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir', type: 'string', - implies: 'dir' + implies: 'dir', }) .option('poll', { desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', - implies: 'watch' + implies: 'watch', }) .option('config', { desc: 'Set a custom directory to look for a config file', - type: 'string' + type: 'string', }) .version(version) .alias('h', 'help') diff --git a/lib/depGraph.js b/lib/depGraph.js index 19bd6b7..783d76e 100644 --- a/lib/depGraph.js +++ b/lib/depGraph.js @@ -4,7 +4,7 @@ const DepGraph = require('dependency-graph').DepGraph const graph = new DepGraph() -exports.add = message => { +exports.add = (message) => { message.parent = path.resolve(message.parent) message.file = path.resolve(message.file) @@ -14,7 +14,7 @@ exports.add = message => { return message } -exports.dependantsOf = node => { +exports.dependantsOf = (node) => { node = path.resolve(node) if (graph.hasNode(node)) return graph.dependantsOf(node) diff --git a/package.json b/package.json index fc09f41..526ed25 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "4.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", - "prettier": "~1.19.1", + "prettier": "~2.0.0", "sugarss": "^2.0.0", "uuid": "^3.0.1" }, diff --git a/test/base.js b/test/base.js index 2a7d383..1bef3e3 100644 --- a/test/base.js +++ b/test/base.js @@ -5,7 +5,7 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--base --dir works', async t => { +test('--base --dir works', async (t) => { const dir = tmp() const { error, stderr } = await cli([ @@ -14,7 +14,7 @@ test('--base --dir works', async t => { dir, '--base', 'test/fixtures/base', - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/cli.js b/test/cli.js index 8cde5dc..d2e449c 100644 --- a/test/cli.js +++ b/test/cli.js @@ -4,14 +4,14 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('works with defaults', async t => { +test('works with defaults', async (t) => { const output = tmp('output.css') const { error, stderr } = await cli([ 'test/fixtures/a.css', '-o', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/config.js b/test/config.js index e654452..774e2f5 100644 --- a/test/config.js +++ b/test/config.js @@ -6,7 +6,7 @@ const ENV = require('./helpers/env.js') const cli = require('./helpers/cli.js') const read = require('./helpers/read.js') -test('supports common config', async t => { +test('supports common config', async (t) => { const env = `module.exports = { plugins: [ require('postcss-import')() @@ -28,7 +28,7 @@ test('supports common config', async t => { ) }) -test("doesn't error on empty config", async t => { +test("doesn't error on empty config", async (t) => { const env = `module.exports = {}` const dir = await ENV(env, ['a.css']) @@ -46,7 +46,7 @@ test("doesn't error on empty config", async t => { ) }) -test('errors if `to` is set', async t => { +test('errors if `to` is set', async (t) => { const env = `module.exports = { to: 'out.css' }` @@ -61,7 +61,7 @@ test('errors if `to` is set', async t => { ) }) -test('errors if `from` is set', async t => { +test('errors if `from` is set', async (t) => { const env = `module.exports = { from: 'in.css' }` diff --git a/test/dir.js b/test/dir.js index 19dd22a..51c0b6e 100644 --- a/test/dir.js +++ b/test/dir.js @@ -5,7 +5,7 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--dir works', async t => { +test('--dir works', async (t) => { const dir = tmp() const { error, stderr } = await cli([ @@ -13,7 +13,7 @@ test('--dir works', async t => { 'test/fixtures/b.css', '--dir', dir, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/error.js b/test/error.js index 1a48b47..e53ce05 100644 --- a/test/error.js +++ b/test/error.js @@ -3,21 +3,21 @@ const test = require('ava') const tmp = require('./helpers/tmp.js') const cli = require('./helpers/cli.js') -test('multiple input files && --output', t => { +test('multiple input files && --output', (t) => { return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(error.toString(), /Input Error: Must use --dir or --replace/) }) }) -test('multiple input files && writing to stdout', t => { +test('multiple input files && writing to stdout', (t) => { return cli(['test/fixtures/*.css']).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(error.toString(), /Input Error: Must use --dir or --replace/) }) }) -test('--map && writing to stdout', t => { +test('--map && writing to stdout', (t) => { return cli(['test/fixtures/a.css', '--map']).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex( @@ -27,20 +27,20 @@ test('--map && writing to stdout', t => { }) }) -test.failing('invalid --config', t => { +test.failing('invalid --config', (t) => { return cli([ 'test/fixtures/*.css', '-c', 'test/postcss.config.js', '-d', - tmp() + tmp(), ]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(error.toString(), /ENOENT: no such file or directory/) }) }) -test('plugin not found', t => { +test('plugin not found', (t) => { return cli(['test/fixtures/a.css', '-u', 'postcss-plugin', '-o', tmp()]).then( ({ error, code }) => { t.is(code, 1, 'expected non-zero error code') @@ -52,20 +52,20 @@ test('plugin not found', t => { ) }) -test('plugin throws on require', t => { +test('plugin throws on require', (t) => { return cli([ 'test/fixtures/a.css', '-u', './test/fixtures/_bad-plugin', '-o', - tmp() + tmp(), ]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') t.regex(error.toString(), /Plugin Error \(.*bad-plugin\): This fails/) }) }) -test('CssSyntaxError', t => { +test('CssSyntaxError', (t) => { return cli(['test/fixtures/a.css', '--parser', 'sugarss', '-o', tmp()]).then( ({ error, code }) => { t.is(code, 1, 'expected non-zero error code') diff --git a/test/ext.js b/test/ext.js index 4edcda9..3f6e883 100644 --- a/test/ext.js +++ b/test/ext.js @@ -6,7 +6,7 @@ const path = require('path') const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') -test('--ext works', async t => { +test('--ext works', async (t) => { const dir = tmp() const { error, stderr } = await cli([ @@ -16,7 +16,7 @@ test('--ext works', async t => { '-d', dir, '--ext', - '.css' + '.css', ]) t.falsy(error, stderr) diff --git a/test/glob.js b/test/glob.js index 2ad919b..574cebb 100644 --- a/test/glob.js +++ b/test/glob.js @@ -5,14 +5,14 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('works with glob patterns', async t => { +test('works with glob patterns', async (t) => { const output = tmp() const { error, stderr } = await cli([ 'test/fixtures/glob/*.css', '-d', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/helpers/clean.js b/test/helpers/clean.js index 6edfe98..526bedf 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -4,8 +4,8 @@ const fs = require('fs-extra') Promise.all([ fs.emptyDir('./test/fixtures/.tmp/'), fs.remove('./coverage'), - fs.remove('./.nyc_output') -]).catch(err => { + fs.remove('./.nyc_output'), +]).catch((err) => { console.error(err) process.exit(1) }) diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 1d44f11..7512439 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,8 +1,8 @@ const path = require('path') const { exec } = require('child_process') -module.exports = function(args, cwd) { - return new Promise(resolve => { +module.exports = function (args, cwd) { + return new Promise((resolve) => { exec( `node ${path.resolve('bin/postcss')} ${args.join(' ')}`, { cwd }, @@ -11,7 +11,7 @@ module.exports = function(args, cwd) { code: error && error.code ? error.code : 0, error, stdout, - stderr + stderr, }) } ) diff --git a/test/helpers/env.js b/test/helpers/env.js index dfafef8..2fad200 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -4,16 +4,16 @@ const globby = require('globby') const tmp = require('./tmp.js') -module.exports = function(config, fixtures) { +module.exports = function (config, fixtures) { fixtures = fixtures || '**/*' const dir = tmp() return Promise.all([ - globby(fixtures, { cwd: 'test/fixtures' }).then(list => { - return list.map(item => { + globby(fixtures, { cwd: 'test/fixtures' }).then((list) => { + return list.map((item) => { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) }), - fs.outputFile(path.join(dir, 'postcss.config.js'), config) + fs.outputFile(path.join(dir, 'postcss.config.js'), config), ]).then(() => dir) } diff --git a/test/helpers/read.js b/test/helpers/read.js index 67de968..3122ee1 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,5 +1,7 @@ const { readFile } = require('fs-extra') -module.exports = function(path) { - return readFile(path, 'utf8').then(content => content.replace(/\r\n/g, '\n')) // normalize line endings on Windows +module.exports = function (path) { + return readFile(path, 'utf8').then( + (content) => content.replace(/\r\n/g, '\n') // normalize line endings on Windows + ) } diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index 0ae40e5..c720b43 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,7 +1,7 @@ const path = require('path') const uuid = require('uuid') -module.exports = function(ext) { +module.exports = function (ext) { ext = ext || '' return path.join('test/fixtures/.tmp', uuid(), ext) diff --git a/test/map.js b/test/map.js index 1497c61..ac64a78 100644 --- a/test/map.js +++ b/test/map.js @@ -7,7 +7,7 @@ const read = require('./helpers/read.js') const getMapfile = require('../lib/getMapfile') -test('inline maps are generated by default', async t => { +test('inline maps are generated by default', async (t) => { const output = tmp('output.css') const { error, stderr } = await cli([ @@ -15,7 +15,7 @@ test('inline maps are generated by default', async t => { '-u', 'postcss-import', '-o', - output + output, ]) t.falsy(error, stderr) @@ -23,7 +23,7 @@ test('inline maps are generated by default', async t => { t.regex(await read(output), /\/*# sourceMappingURL=/) }) -test('--map generates external sourcemaps', async t => { +test('--map generates external sourcemaps', async (t) => { const output = tmp('output.css') const { error, stderr } = await cli([ @@ -32,7 +32,7 @@ test('--map generates external sourcemaps', async t => { 'postcss-import', '-o', output, - '--map' + '--map', ]) t.falsy(error, stderr) @@ -40,7 +40,7 @@ test('--map generates external sourcemaps', async t => { t.truthy(await fs.pathExists(output.replace('.css', '.css.map'))) }) -test('--no-map disables internal sourcemaps', async t => { +test('--no-map disables internal sourcemaps', async (t) => { const output = tmp('output.css') const { error, stderr } = await cli([ @@ -49,31 +49,31 @@ test('--no-map disables internal sourcemaps', async t => { 'postcss-import', '-o', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) t.notRegex(await read(output), /\/*# sourceMappingURL=/) }) -test('mapFile path is property resolved', async t => { +test('mapFile path is property resolved', async (t) => { const paths = [ { input: { to: '/foo/bar.css/baz/index.css' }, - want: '/foo/bar.css/baz/index.css.map' + want: '/foo/bar.css/baz/index.css.map', }, { input: { to: '/foo/bar.sss/baz/index.sss' }, - want: '/foo/bar.sss/baz/index.sss.map' + want: '/foo/bar.sss/baz/index.sss.map', }, { input: { to: '/foo/bar.css/baz/bar.css' }, - want: '/foo/bar.css/baz/bar.css.map' + want: '/foo/bar.css/baz/bar.css.map', }, { input: { map: { annotation: 'foo.map' }, to: '/foo/bar.css/baz/bar.css' }, - want: '/foo/bar.css/baz/foo.map' - } + want: '/foo/bar.css/baz/foo.map', + }, ] for (const p of paths) { diff --git a/test/misc.js b/test/misc.js index b9b7415..1c1084e 100644 --- a/test/misc.js +++ b/test/misc.js @@ -2,7 +2,7 @@ const test = require('ava') const cli = require('./helpers/cli.js') -test('--help', async t => { +test('--help', async (t) => { const help = await cli(['--help']) t.falsy(help.error) @@ -10,7 +10,7 @@ test('--help', async t => { t.truthy(help.stdout.length > 10, 'expected --help to output a help message') }) -test('--version', async t => { +test('--version', async (t) => { const version = await cli(['--version']) t.falsy(version.error) diff --git a/test/parser.js b/test/parser.js index 7e6ab5c..4c56abb 100644 --- a/test/parser.js +++ b/test/parser.js @@ -4,7 +4,7 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--parser works', async t => { +test('--parser works', async (t) => { const output = tmp('output.css') const { error, stderr } = await cli([ @@ -13,7 +13,7 @@ test('--parser works', async t => { 'sugarss', '-o', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/replace.js b/test/replace.js index 51cfe96..5b48ad4 100644 --- a/test/replace.js +++ b/test/replace.js @@ -7,14 +7,14 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--replace works', async t => { +test('--replace works', async (t) => { const dir = tmp() const output = path.join(dir, 'output.css') await Promise.all([ fs.copy('test/fixtures/import.css', output), - fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')) + fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')), ]) const { error, stderr } = await cli([ @@ -22,7 +22,7 @@ test('--replace works', async t => { '--replace', '-u', 'postcss-import', - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/stdin.js b/test/stdin.js index 695f5e6..867145c 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -7,7 +7,7 @@ const { exec } = require('child_process') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test.cb('reads from stdin', t => { +test.cb('reads from stdin', (t) => { const output = tmp('output.css') const cp = exec( diff --git a/test/stdout.js b/test/stdout.js index 4ea43c4..9b26ad4 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -6,7 +6,7 @@ const { exec } = require('child_process') const read = require('./helpers/read.js') -test.cb('writes to stdout', t => { +test.cb('writes to stdout', (t) => { const cp = exec( `node ${path.resolve( 'bin/postcss' diff --git a/test/stringifier.js b/test/stringifier.js index beb5e70..4256c79 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -4,7 +4,7 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--stringifier works', async t => { +test('--stringifier works', async (t) => { const output = tmp('output.sss') const { error, stderr } = await cli([ @@ -13,7 +13,7 @@ test('--stringifier works', async t => { 'sugarss', '-o', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/syntax.js b/test/syntax.js index a4a42c8..4658d69 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -4,7 +4,7 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--syntax works', async t => { +test('--syntax works', async (t) => { const output = tmp('output.sss') const { error, stderr } = await cli([ @@ -13,7 +13,7 @@ test('--syntax works', async t => { 'sugarss', '-o', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/use.js b/test/use.js index f53650f..07901f6 100644 --- a/test/use.js +++ b/test/use.js @@ -4,7 +4,7 @@ const cli = require('./helpers/cli.js') const tmp = require('./helpers/tmp.js') const read = require('./helpers/read.js') -test('--use works', async t => { +test('--use works', async (t) => { const output = tmp('i.css') const { error, stderr } = await cli([ @@ -13,7 +13,7 @@ test('--use works', async t => { 'postcss-import', '-o', output, - '--no-map' + '--no-map', ]) t.falsy(error, stderr) diff --git a/test/watch.js b/test/watch.js index 993c873..6012bf7 100644 --- a/test/watch.js +++ b/test/watch.js @@ -11,33 +11,33 @@ const read = require('./helpers/read.js') // XXX: All the tests in this file are skipped on the CI; too flacky there const testCb = process.env.CI ? test.cb.skip : test.cb -testCb('--watch works', t => { +testCb('--watch works', (t) => { let cp t.plan(2) ENV('', ['a.css']) - .then(dir => { + .then((dir) => { // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, - awaitWriteFinish: true + awaitWriteFinish: true, }) // On the first output: - watcher.on('add', p => { + watcher.on('add', (p) => { // Assert, then change the source file if (p === 'output.css') { isEqual(p, 'test/fixtures/a.css') .then(() => read('test/fixtures/b.css')) - .then(css => fs.writeFile(path.join(dir, 'a.css'), css)) + .then((css) => fs.writeFile(path.join(dir, 'a.css'), css)) .catch(done) } }) // When the change is picked up: - watcher.on('change', p => { + watcher.on('change', (p) => { if (p === 'output.css') { isEqual(p, 'test/fixtures/b.css') .then(() => done()) @@ -55,7 +55,7 @@ testCb('--watch works', t => { { cwd: dir } ) cp.on('error', t.end) - cp.on('exit', code => { + cp.on('exit', (code) => { if (code) t.end(code) }) }) @@ -64,7 +64,7 @@ testCb('--watch works', t => { function isEqual(p, expected) { return Promise.all([ read(path.join(dir, p)), - read(expected) + read(expected), ]).then(([a, e]) => t.is(a, e)) } @@ -82,26 +82,26 @@ testCb('--watch works', t => { setTimeout(() => t.end('test timeout'), 50000) }) -testCb('--watch postcss.config.js', t => { +testCb('--watch postcss.config.js', (t) => { let cp t.plan(2) ENV('module.exports = {}', ['import.css', 'a.css']) - .then(dir => { + .then((dir) => { // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, - awaitWriteFinish: true + awaitWriteFinish: true, }) // On the first output: - watcher.on('add', p => { + watcher.on('add', (p) => { // Assert, then change the source file if (p === 'output.css') { read(path.join(dir, p)) - .then(css => { + .then((css) => { t.is(css, '@import "./a.css";\n') return fs.writeFile( @@ -118,7 +118,7 @@ testCb('--watch postcss.config.js', t => { }) // When the change is picked up: - watcher.on('change', p => { + watcher.on('change', (p) => { if (p === 'output.css') { isEqual(p, 'test/fixtures/a.css') .then(() => done()) @@ -136,7 +136,7 @@ testCb('--watch postcss.config.js', t => { ) cp.on('error', t.end) - cp.on('exit', code => { + cp.on('exit', (code) => { if (code) t.end(code) }) }) @@ -145,7 +145,7 @@ testCb('--watch postcss.config.js', t => { function isEqual(p, expected) { return Promise.all([ read(path.join(dir, p)), - read(expected) + read(expected), ]).then(([a, e]) => t.is(a, e)) } @@ -163,33 +163,33 @@ testCb('--watch postcss.config.js', t => { setTimeout(() => t.end('test timeout'), 50000) }) -testCb('--watch dependencies', t => { +testCb('--watch dependencies', (t) => { let cp t.plan(2) ENV('', ['import.css', 'a.css']) - .then(dir => { + .then((dir) => { // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, - awaitWriteFinish: true + awaitWriteFinish: true, }) // On the first output: - watcher.on('add', p => { + watcher.on('add', (p) => { // Assert, then change the source file if (p === 'output.css') { isEqual(p, 'test/fixtures/a.css') .then(() => read('test/fixtures/b.css')) - .then(css => fs.writeFile(path.join(dir, 'a.css'), css)) + .then((css) => fs.writeFile(path.join(dir, 'a.css'), css)) .catch(done) } }) // When the change is picked up: - watcher.on('change', p => { + watcher.on('change', (p) => { if (p === 'output.css') { isEqual(p, 'test/fixtures/b.css') .then(() => done()) @@ -207,7 +207,7 @@ testCb('--watch dependencies', t => { ) cp.on('error', t.end) - cp.on('exit', code => { + cp.on('exit', (code) => { if (code) t.end(code) }) }) @@ -216,7 +216,7 @@ testCb('--watch dependencies', t => { function isEqual(p, expected) { return Promise.all([ read(path.join(dir, p)), - read(expected) + read(expected), ]).then(([a, e]) => t.is(a, e)) } @@ -233,18 +233,18 @@ testCb('--watch dependencies', t => { setTimeout(() => t.end('test timeout'), 50000) }) -testCb("--watch doesn't exit on CssSyntaxError", t => { +testCb("--watch doesn't exit on CssSyntaxError", (t) => { t.plan(0) ENV('', ['a.css']) - .then(dir => { + .then((dir) => { // Init watcher: const watcher = chokidar.watch('.', { cwd: dir, ignoreInitial: true, - awaitWriteFinish: true + awaitWriteFinish: true, }) - watcher.on('add', p => { + watcher.on('add', (p) => { if (p === 'output.css') { // Change to invalid CSS fs.writeFile(path.join(dir, 'a.css'), '.a { color: red').catch(done) @@ -257,7 +257,7 @@ testCb("--watch doesn't exit on CssSyntaxError", t => { { cwd: dir } ) cp.on('error', t.end) - cp.stderr.on('data', chunk => { + cp.stderr.on('data', (chunk) => { // When error message is printed, kill the process after a timeout if (~chunk.indexOf('Unclosed block')) { setTimeout(() => { @@ -266,7 +266,7 @@ testCb("--watch doesn't exit on CssSyntaxError", t => { }, 1000) } }) - cp.on('exit', code => { + cp.on('exit', (code) => { if (!killed) return t.end(`Should not exit (exited with code ${code})`) done() }) From 47104bc41ee3d0fd327c9964fd9526d8020c3718 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2020 10:44:51 -0400 Subject: [PATCH 129/251] Update dependency chalk to v4 (#322) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 526ed25..512f15e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test": "nyc ava -v" }, "dependencies": { - "chalk": "^3.0.0", + "chalk": "^4.0.0", "chokidar": "^3.3.0", "dependency-graph": "^0.9.0", "fs-extra": "^9.0.0", From 7a9c4efc313cc3ec919fa16760d099f455cb9d91 Mon Sep 17 00:00:00 2001 From: Lee Powell Date: Sat, 25 Apr 2020 19:56:54 +0100 Subject: [PATCH 130/251] Fix: External source maps not being generated (#324) * Fix: External source maps not being generated * Removed package-lock.json --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 92358b7..187b9bc 100644 --- a/index.js +++ b/index.js @@ -223,7 +223,7 @@ function css(css, file) { if (result.map) { const mapfile = getMapfile(options) - tasks.push(fs.outputFile(mapfile, result.map)) + tasks.push(fs.outputFile(mapfile, result.map.toString())) } } else process.stdout.write(result.css, 'utf8') From 8b39a4e2400e68021b7b293e0c8034964fcafdee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 25 Apr 2020 15:22:31 -0400 Subject: [PATCH 131/251] Update dependency uuid to v7 (#318) * Update dependency uuid to v7 * Change usage Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- package.json | 2 +- test/helpers/tmp.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 512f15e..b009b92 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "postcss-import": "^12.0.0", "prettier": "~2.0.0", "sugarss": "^2.0.0", - "uuid": "^3.0.1" + "uuid": "^7.0.0" }, "files": [ "bin", diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index c720b43..f084dea 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,5 +1,5 @@ const path = require('path') -const uuid = require('uuid') +const { v4: uuid } = require('uuid') module.exports = function (ext) { ext = ext || '' From 0758cd131c369ec482170768c0a6ae8b7d0d8ca8 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Sat, 25 Apr 2020 15:48:14 -0400 Subject: [PATCH 132/251] Do not use package-lock.json --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false From d2e76781e14eb2a836b80a2e24aca54a8930b96d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 27 Apr 2020 13:12:20 -0400 Subject: [PATCH 133/251] 7.1.1 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e24e3..7fb244e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 7.1.1 / 2020-04-27 + +- Fix bug where external source maps were not properly generated ([#324](https://github.com/postcss/postcss-cli/pull/324)) +- Update dependencies + # 7.1.0 / 2020-01-09 - Respect `map.annotation` option when set to a string ([#307](https://github.com/postcss/postcss-cli/pull/307)) diff --git a/package.json b/package.json index b009b92..51ceeeb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "7.1.0", + "version": "7.1.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 5df1399051be28acd84f8cdd0cf4de13052f2af9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2020 10:39:53 -0400 Subject: [PATCH 134/251] Update dependency uuid to v8 (#325) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51ceeeb..4513502 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "postcss-import": "^12.0.0", "prettier": "~2.0.0", "sugarss": "^2.0.0", - "uuid": "^7.0.0" + "uuid": "^8.0.0" }, "files": [ "bin", From e2bed8c30fea21b8a2aa3b24f02edf2d023b2bad Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 12 May 2020 10:37:41 -0400 Subject: [PATCH 135/251] Update dependency get-stdin to v8 (#327) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4513502..12ab196 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "chokidar": "^3.3.0", "dependency-graph": "^0.9.0", "fs-extra": "^9.0.0", - "get-stdin": "^7.0.0", + "get-stdin": "^8.0.0", "globby": "^11.0.0", "postcss": "^7.0.0", "postcss-load-config": "^2.0.0", From 91d6ef69af17f7289d3821c5903856bcf6496f4a Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 31 Aug 2020 20:53:55 -0400 Subject: [PATCH 136/251] Output plain version number (#335) Fixes #334 --- lib/args.js | 14 -------------- test/misc.js | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/args.js b/lib/args.js index 9172a93..9ab1dae 100644 --- a/lib/args.js +++ b/lib/args.js @@ -13,19 +13,6 @@ const logo = ` //_____||___*_________*___||_____// ` -const cli = require('../package.json').version -const version = chalk.bold.red(` - /|\\ - // // - // // - //___*___*___// - //--*---------*--// - /|| * * ||/ - // ||* v${cli} *|| // - // || * * || // - //_____||___*_________*___||_____// -`) - module.exports = require('yargs') .usage( `${chalk.bold.red(logo)} @@ -125,7 +112,6 @@ Usage: desc: 'Set a custom directory to look for a config file', type: 'string', }) - .version(version) .alias('h', 'help') .example('$0 input.css -o output.css', 'Basic usage') .example('$0 src/**/*.css --base src --dir build', 'Glob Pattern & output') diff --git a/test/misc.js b/test/misc.js index 1c1084e..29a736c 100644 --- a/test/misc.js +++ b/test/misc.js @@ -16,7 +16,7 @@ test('--version', async (t) => { t.falsy(version.error) t.truthy( - version.stdout.length > 10, + version.stdout.length > 5, 'expected --version to output version info' ) }) From a36f630680961b3d49a2b0d3f5d133294271edfc Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 31 Aug 2020 20:54:09 -0400 Subject: [PATCH 137/251] Organize and clarify --help text (#336) --- README.md | 46 +++++++++++++++++++++++++--------------------- lib/args.js | 29 +++++++++++++++-------------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 4eeb62a..50bade6 100644 --- a/README.md +++ b/README.md @@ -30,33 +30,36 @@ Usage: postcss ... [OPTIONS] --replace Basic options: - -o, --output Output file [string] - -d, --dir Output directory [string] - -r, --replace Replace (overwrite) the input file [boolean] - --map, -m Create an external sourcemap - --no-map Disable the default inline sourcemaps - --verbose Be verbose [boolean] - --watch, -w Watch files for changes and recompile as needed [boolean] - --env A shortcut for setting NODE_ENV [string] - --include-dotfiles Enables glob to match files/dirs that begin with "." [boolean] - -Options for when not using a config file: + -o, --output Output file [string] + -d, --dir Output directory [string] + -r, --replace Replace (overwrite) the input file [boolean] + -m, --map Create an external sourcemap + --no-map Disable the default inline sourcemaps + -w, --watch Watch files for changes and recompile as needed [boolean] + --verbose Be verbose [boolean] + --env A shortcut for setting NODE_ENV [string] + +Options for use without a config file: -u, --use List of postcss plugins to use [array] --parser Custom postcss parser [string] --stringifier Custom postcss stringifier [string] --syntax Custom postcss syntax [string] +Options for use with --dir: + --ext Override the output file extension; for use with --dir [string] + --base Mirror the directory structure relative to this path in the output + directory, for use with --dir [string] + Advanced options: - --ext Override the output file extension; for use with --dir [string] - --base Mirror the directory structure relative to this path in the output - directory, for use with --dir [string] - --poll Use polling for file watching. Can optionally pass polling interval; - default 100 ms - --config Set a custom directory to look for a config file [string] + --include-dotfiles Enable glob to match files/dirs that begin with "." + [boolean] + --poll Use polling for file watching. Can optionally pass polling + interval; default 100 ms + --config Set a custom directory to look for a config file [string] Options: - --version Show version number [boolean] - -h, --help Show help [boolean] + --version Show version number [boolean] + -h, --help Show help [boolean] Examples: postcss input.css -o output.css Basic usage @@ -68,8 +71,9 @@ If no input files are passed, it reads from stdin. If neither -o, --dir, or If there are multiple input files, the --dir or --replace option must be passed. -Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process -all files in the directory and any subdirectories, respecting the glob pattern. +Input files may contain globs (e.g. src/**/*.css). If you pass an input +directory, it will process all files in the directory and any subdirectories, +respecting the glob pattern. ``` > ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). diff --git a/lib/args.js b/lib/args.js index 9ab1dae..b027bb4 100644 --- a/lib/args.js +++ b/lib/args.js @@ -24,7 +24,7 @@ Usage: $0 ... [OPTIONS] --replace` ) .group( - ['o', 'd', 'r', 'map', 'no-map', 'verbose', 'watch', 'env'], + ['o', 'd', 'r', 'map', 'no-map', 'watch', 'verbose', 'env'], 'Basic options:' ) .option('o', { @@ -45,30 +45,26 @@ Usage: type: 'boolean', conflicts: ['output', 'dir'], }) - .option('include-dotfiles', { - desc: 'Enables glob to match files/dirs that begin with "."', - type: 'boolean', - }) - .alias('map', 'm') + .alias('m', 'map') .describe('map', 'Create an external sourcemap') .describe('no-map', 'Disable the default inline sourcemaps') - .option('verbose', { - desc: 'Be verbose', - type: 'boolean', - }) - .option('watch', { - alias: 'w', + .option('w', { + alias: 'watch', desc: 'Watch files for changes and recompile as needed', type: 'boolean', conflicts: 'replace', }) + .option('verbose', { + desc: 'Be verbose', + type: 'boolean', + }) .option('env', { desc: 'A shortcut for setting NODE_ENV', type: 'string', }) .group( ['u', 'parser', 'stringifier', 'syntax'], - 'Options for when not using a config file:' + 'Options for use without a config file:' ) .option('u', { alias: 'use', @@ -87,7 +83,7 @@ Usage: desc: 'Custom postcss syntax', type: 'string', }) - .group(['ext', 'base', 'poll', 'config'], 'Advanced options:') + .group(['ext', 'base'], 'Options for use with --dir:') .option('ext', { desc: 'Override the output file extension; for use with --dir', type: 'string', @@ -103,6 +99,11 @@ Usage: type: 'string', implies: 'dir', }) + .group(['include-dotfiles', 'poll', 'config'], 'Advanced options:') + .option('include-dotfiles', { + desc: 'Enable glob to match files/dirs that begin with "."', + type: 'boolean', + }) .option('poll', { desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', From d94f0c6559cad74d09a7429cd62c1ec385c13440 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 31 Aug 2020 20:59:40 -0400 Subject: [PATCH 138/251] 7.1.2 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fb244e..f1e0ce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 7.1.2 / 2020-08-31 + +- Make `--version` machine-readable ([#334](https://github.com/postcss/postcss-cli/issues/334), [#335](https://github.com/postcss/postcss-cli/pull/335)) +- Organize and clarify `--help` text ([#336](https://github.com/postcss/postcss-cli/pull/336)) +- Update dependencies + # 7.1.1 / 2020-04-27 - Fix bug where external source maps were not properly generated ([#324](https://github.com/postcss/postcss-cli/pull/324)) diff --git a/package.json b/package.json index 12ab196..0588ea6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "7.1.1", + "version": "7.1.2", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 031aa10b4b31b33605f7b74ffcf006484724bc0e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2020 21:07:40 -0400 Subject: [PATCH 139/251] Update dependency prettier to ~2.1.0 (#337) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0588ea6..390a175 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "4.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", - "prettier": "~2.0.0", + "prettier": "~2.1.0", "sugarss": "^2.0.0", "uuid": "^8.0.0" }, From 77d2c1d1f297f30c64e28ce59aea5996c1a362b6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 31 Aug 2020 21:30:13 -0400 Subject: [PATCH 140/251] Clean up 'use strict' usage --- test/.eslintrc.yaml | 2 -- test/base.js | 1 + test/cli.js | 1 + test/config.js | 1 + test/dir.js | 1 + test/error.js | 1 + test/ext.js | 1 + test/fixtures/_bad-plugin.js | 1 + test/glob.js | 1 + test/helpers/clean.js | 2 +- test/helpers/cli.js | 1 + test/helpers/env.js | 1 + test/helpers/read.js | 1 + test/helpers/tmp.js | 1 + test/map.js | 1 + test/misc.js | 1 + test/parser.js | 1 + test/replace.js | 1 + test/stdin.js | 1 + test/stdout.js | 1 + test/stringifier.js | 1 + test/syntax.js | 1 + test/use.js | 1 + test/watch.js | 1 + 24 files changed, 23 insertions(+), 3 deletions(-) delete mode 100644 test/.eslintrc.yaml diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml deleted file mode 100644 index add5a78..0000000 --- a/test/.eslintrc.yaml +++ /dev/null @@ -1,2 +0,0 @@ -parserOptions: - sourceType: module diff --git a/test/base.js b/test/base.js index 1bef3e3..32eff27 100644 --- a/test/base.js +++ b/test/base.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/cli.js b/test/cli.js index d2e449c..0cdc7dc 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/config.js b/test/config.js index 774e2f5..b8b3de5 100644 --- a/test/config.js +++ b/test/config.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/dir.js b/test/dir.js index 51c0b6e..ec4e60e 100644 --- a/test/dir.js +++ b/test/dir.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/error.js b/test/error.js index e53ce05..4dace3c 100644 --- a/test/error.js +++ b/test/error.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const tmp = require('./helpers/tmp.js') diff --git a/test/ext.js b/test/ext.js index 3f6e883..7016782 100644 --- a/test/ext.js +++ b/test/ext.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/fixtures/_bad-plugin.js b/test/fixtures/_bad-plugin.js index 2911e95..7a4ffeb 100644 --- a/test/fixtures/_bad-plugin.js +++ b/test/fixtures/_bad-plugin.js @@ -1 +1,2 @@ +'use strict' throw new Error('This fails') diff --git a/test/glob.js b/test/glob.js index 574cebb..e60b75a 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const path = require('path') diff --git a/test/helpers/clean.js b/test/helpers/clean.js index 526bedf..cabfc72 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -1,4 +1,4 @@ -'use strict' // eslint-disable-line +'use strict' const fs = require('fs-extra') Promise.all([ diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 7512439..64b9154 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,3 +1,4 @@ +'use strict' const path = require('path') const { exec } = require('child_process') diff --git a/test/helpers/env.js b/test/helpers/env.js index 2fad200..b389370 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,3 +1,4 @@ +'use strict' const fs = require('fs-extra') const path = require('path') const globby = require('globby') diff --git a/test/helpers/read.js b/test/helpers/read.js index 3122ee1..88b6421 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,3 +1,4 @@ +'use strict' const { readFile } = require('fs-extra') module.exports = function (path) { diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index f084dea..a23fa35 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,3 +1,4 @@ +'use strict' const path = require('path') const { v4: uuid } = require('uuid') diff --git a/test/map.js b/test/map.js index ac64a78..04f90fd 100644 --- a/test/map.js +++ b/test/map.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/misc.js b/test/misc.js index 29a736c..9240e32 100644 --- a/test/misc.js +++ b/test/misc.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/parser.js b/test/parser.js index 4c56abb..1ac9805 100644 --- a/test/parser.js +++ b/test/parser.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/replace.js b/test/replace.js index 5b48ad4..f2712a2 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/stdin.js b/test/stdin.js index 867145c..8709a94 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/stdout.js b/test/stdout.js index 9b26ad4..8bd5d7b 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') diff --git a/test/stringifier.js b/test/stringifier.js index 4256c79..db3ef28 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/syntax.js b/test/syntax.js index 4658d69..c4295f9 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/use.js b/test/use.js index 07901f6..25400f6 100644 --- a/test/use.js +++ b/test/use.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const cli = require('./helpers/cli.js') diff --git a/test/watch.js b/test/watch.js index 6012bf7..b5bce40 100644 --- a/test/watch.js +++ b/test/watch.js @@ -1,3 +1,4 @@ +'use strict' const test = require('ava') const fs = require('fs-extra') From 1c3ebba359cc4702c2094b1a28ef5a678e930dc6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Tue, 1 Sep 2020 10:40:13 -0400 Subject: [PATCH 141/251] Upgrade eslint & eslint-config-problems (#339) Closes #326 Closes #338 --- lib/depGraph.js | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/depGraph.js b/lib/depGraph.js index 783d76e..ace18be 100644 --- a/lib/depGraph.js +++ b/lib/depGraph.js @@ -1,6 +1,6 @@ 'use strict' const path = require('path') -const DepGraph = require('dependency-graph').DepGraph +const { DepGraph } = require('dependency-graph') const graph = new DepGraph() diff --git a/package.json b/package.json index 390a175..12c5763 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ "devDependencies": { "ava": "^3.1.0", "coveralls": "^3.0.0", - "eslint": "^6.8.0", - "eslint-config-problems": "4.0.0", + "eslint": "^7.8.0", + "eslint-config-problems": "5.0.0", "nyc": "^15.0.0", "postcss-import": "^12.0.0", "prettier": "~2.1.0", From 66b6055d3cf8b1960b4e83131d06f1f382940e16 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2020 12:47:41 -0400 Subject: [PATCH 142/251] Update dependency yargs to v16 (#340) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12c5763..7a9487a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "postcss-reporter": "^6.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "yargs": "^15.0.2" + "yargs": "^16.0.0" }, "devDependencies": { "ava": "^3.1.0", From a4998fafdf40e58c299565676ac26137219592d5 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 21 Sep 2020 12:48:10 -0400 Subject: [PATCH 143/251] Support postcss v8 (#349) * Support postcss v8 Fixes #344 Closes #348, closes #345, closes #343. * Don't promote global installs --- README.md | 2 +- package.json | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 50bade6..71db6e6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@

Install

```bash -npm i -g|-D postcss-cli +npm i -D postcss postcss-cli ```

Usage

diff --git a/package.json b/package.json index 7a9487a..0237360 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,8 @@ "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", - "postcss": "^7.0.0", - "postcss-load-config": "^2.0.0", - "postcss-reporter": "^6.0.0", + "postcss-load-config": "^2.1.1", + "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "yargs": "^16.0.0" @@ -37,11 +36,15 @@ "eslint": "^7.8.0", "eslint-config-problems": "5.0.0", "nyc": "^15.0.0", + "postcss": "^8.0.4", "postcss-import": "^12.0.0", "prettier": "~2.1.0", - "sugarss": "^2.0.0", + "sugarss": "^3.0.0", "uuid": "^8.0.0" }, + "peerDependencies": { + "postcss": "^8.0.0" + }, "files": [ "bin", "index.js", From ed69076bea45df66dcde8f317af3e886f5706f1c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 21 Sep 2020 13:06:59 -0400 Subject: [PATCH 144/251] Remove obsolete failing test Fixes #123 --- test/error.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/error.js b/test/error.js index 4dace3c..38b972b 100644 --- a/test/error.js +++ b/test/error.js @@ -28,19 +28,6 @@ test('--map && writing to stdout', (t) => { }) }) -test.failing('invalid --config', (t) => { - return cli([ - 'test/fixtures/*.css', - '-c', - 'test/postcss.config.js', - '-d', - tmp(), - ]).then(({ error, code }) => { - t.is(code, 1, 'expected non-zero error code') - t.regex(error.toString(), /ENOENT: no such file or directory/) - }) -}) - test('plugin not found', (t) => { return cli(['test/fixtures/a.css', '-u', 'postcss-plugin', '-o', tmp()]).then( ({ error, code }) => { From 9e03d5c001a68027d569bf8c10fe3e448a40851d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Mon, 21 Sep 2020 13:53:28 -0400 Subject: [PATCH 145/251] 8.0.0 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e0ce1..eba276a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 8.0.0 / 2020-09-21 + +- **BREAKING:** Support postcss v8 ([#344](https://github.com/postcss/postcss-cli/issues/344), [#349](https://github.com/postcss/postcss-cli/pull/349)) +- **BREAKING:** postcss is now a `peerDependency`, you must install it seperately ([#344](https://github.com/postcss/postcss-cli/issues/344), [#349](https://github.com/postcss/postcss-cli/pull/349)) +- Upgrade dependencies ([#340](https://github.com/postcss/postcss-cli/pull/340)) + # 7.1.2 / 2020-08-31 - Make `--version` machine-readable ([#334](https://github.com/postcss/postcss-cli/issues/334), [#335](https://github.com/postcss/postcss-cli/pull/335)) diff --git a/package.json b/package.json index 0237360..75a7200 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "7.1.2", + "version": "8.0.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 8aa4f6e8c9f963e3e8cac19c8d2f80133be6595c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2020 11:18:39 -0400 Subject: [PATCH 146/251] Update dependency postcss-load-config to v3 (#351) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75a7200..db5b53a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", - "postcss-load-config": "^2.1.1", + "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From 8ef4c1fc2b7bcbc754f1a8f276578d7f6ec1aa39 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Thu, 8 Oct 2020 18:20:04 -0400 Subject: [PATCH 147/251] Add tests for DependencyGraph (#354) * Make depGraph testable * Add tests for DependencyGraph --- index.js | 3 ++- lib/DependencyGraph.js | 24 ++++++++++++++++++++++++ lib/DependencyGraph.test.js | 20 ++++++++++++++++++++ lib/depGraph.js | 22 ---------------------- package.json | 3 ++- 5 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 lib/DependencyGraph.js create mode 100644 lib/DependencyGraph.test.js delete mode 100644 lib/depGraph.js diff --git a/index.js b/index.js index 187b9bc..aeccc51 100644 --- a/index.js +++ b/index.js @@ -15,8 +15,9 @@ const postcssrc = require('postcss-load-config') const reporter = require('postcss-reporter/lib/formatter')() const argv = require('./lib/args') -const depGraph = require('./lib/depGraph') +const createDependencyGraph = require('./lib/DependencyGraph') const getMapfile = require('./lib/getMapfile') +const depGraph = createDependencyGraph() let input = argv._ const { dir, output } = argv diff --git a/lib/DependencyGraph.js b/lib/DependencyGraph.js new file mode 100644 index 0000000..03fae2e --- /dev/null +++ b/lib/DependencyGraph.js @@ -0,0 +1,24 @@ +'use strict' +const path = require('path') +const { DepGraph } = require('dependency-graph') + +module.exports = function () { + const graph = new DepGraph() + return { + add(message) { + message.parent = path.resolve(message.parent) + message.file = path.resolve(message.file) + + graph.addNode(message.parent) + graph.addNode(message.file) + graph.addDependency(message.parent, message.file) + return message + }, + dependantsOf(node) { + node = path.resolve(node) + + if (graph.hasNode(node)) return graph.dependantsOf(node) + return [] + }, + } +} diff --git a/lib/DependencyGraph.test.js b/lib/DependencyGraph.test.js new file mode 100644 index 0000000..a0235ba --- /dev/null +++ b/lib/DependencyGraph.test.js @@ -0,0 +1,20 @@ +'use strict' +const test = require('ava') +const path = require('path') +const createDependencyGraph = require('./DependencyGraph.js') + +function resolveArray(arr) { + return arr.map((p) => path.resolve(p)) +} + +test('tracks dependencies', (t) => { + const graph = createDependencyGraph() + graph.add({ file: 'aa', parent: 'a' }) + graph.add({ file: 'bb', parent: 'b' }) + graph.add({ file: 'ab', parent: 'a' }) + graph.add({ file: 'ab', parent: 'b' }) + t.deepEqual(graph.dependantsOf('aa'), resolveArray(['a'])) + t.deepEqual(graph.dependantsOf('bb'), resolveArray(['b'])) + t.deepEqual(graph.dependantsOf('ab'), resolveArray(['a', 'b'])) + t.deepEqual(graph.dependantsOf('nonexistent'), []) +}) diff --git a/lib/depGraph.js b/lib/depGraph.js deleted file mode 100644 index ace18be..0000000 --- a/lib/depGraph.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict' -const path = require('path') -const { DepGraph } = require('dependency-graph') - -const graph = new DepGraph() - -exports.add = (message) => { - message.parent = path.resolve(message.parent) - message.file = path.resolve(message.file) - - graph.addNode(message.parent) - graph.addNode(message.file) - graph.addDependency(message.parent, message.file) - return message -} - -exports.dependantsOf = (node) => { - node = path.resolve(node) - - if (graph.hasNode(node)) return graph.dependantsOf(node) - return [] -} diff --git a/package.json b/package.json index db5b53a..859470b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "files": [ "bin", "index.js", - "lib" + "lib", + "!*.test.js" ], "keywords": [ "cli", From c94c1885a97f30627ba31c386fce0d8eed483a71 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 8 Oct 2020 18:23:20 -0400 Subject: [PATCH 148/251] 8.1.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba276a..3b5ff99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.1.0 / 2020-10-08 + +- Add support for `postcss.config.cjs` files ([#351](https://github.com/postcss/postcss-cli/pull/351)) + # 8.0.0 / 2020-09-21 - **BREAKING:** Support postcss v8 ([#344](https://github.com/postcss/postcss-cli/issues/344), [#349](https://github.com/postcss/postcss-cli/pull/349)) diff --git a/package.json b/package.json index 859470b..5f55fed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.0.0", + "version": "8.1.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From c634575b3d838037a908cad3830ef3ebddc861b8 Mon Sep 17 00:00:00 2001 From: Matthias Christen Date: Tue, 20 Oct 2020 16:29:52 +0200 Subject: [PATCH 149/251] Use 'slash' on input files before globbing to support absolute paths with backslashes on Windows (#355) --- index.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index aeccc51..edc7a3f 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const stdin = require('get-stdin') const read = require('read-cache') const chalk = require('chalk') const globber = require('globby') +const slash = require('slash') const chokidar = require('chokidar') const postcss = require('postcss') @@ -57,7 +58,7 @@ Promise.resolve() } if (input && input.length) { - return globber(input, { dot: argv.includeDotfiles }) + return globber(input.map(slash), { dot: argv.includeDotfiles }) } if (argv.replace || argv.dir) { diff --git a/package.json b/package.json index 5f55fed..7ababaa 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", + "slash": "^3.0.0", "yargs": "^16.0.0" }, "devDependencies": { From e279de81cb48a008070fea20f9db2e6db2feb675 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 29 Oct 2020 18:41:19 -0400 Subject: [PATCH 150/251] 8.2.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5ff99..c74cd37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.2.0 / 2020-10-29 + +- Allow backslashes in paths for better Windows experence ([#355](https://github.com/postcss/postcss-cli/pull/355)) + # 8.1.0 / 2020-10-08 - Add support for `postcss.config.cjs` files ([#351](https://github.com/postcss/postcss-cli/pull/351)) diff --git a/package.json b/package.json index 7ababaa..88a0b34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.1.0", + "version": "8.2.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From b19fbdc07718dfad6d8cd501219be6bb2705960b Mon Sep 17 00:00:00 2001 From: Timmo Verlaan Date: Tue, 17 Nov 2020 01:42:58 +0100 Subject: [PATCH 151/251] Exit watch process on EOF / Ctrl-D (#358) --- index.js | 5 +++++ test/watch.js | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index edc7a3f..47a6e5a 100644 --- a/index.js +++ b/index.js @@ -51,6 +51,11 @@ let configFile if (argv.env) process.env.NODE_ENV = argv.env if (argv.config) argv.config = path.resolve(argv.config) +if (argv.watch) { + process.stdin.on('end', () => process.exit(0)) + process.stdin.resume() +} + Promise.resolve() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { diff --git a/test/watch.js b/test/watch.js index b5bce40..4a51a11 100644 --- a/test/watch.js +++ b/test/watch.js @@ -3,11 +3,12 @@ const test = require('ava') const fs = require('fs-extra') const path = require('path') -const { exec } = require('child_process') +const { exec, spawn } = require('child_process') const chokidar = require('chokidar') const ENV = require('./helpers/env.js') const read = require('./helpers/read.js') +const tmp = require('./helpers/tmp.js') // XXX: All the tests in this file are skipped on the CI; too flacky there const testCb = process.env.CI ? test.cb.skip : test.cb @@ -285,3 +286,19 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => { // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) + +testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { + t.plan(1) + + const cp = spawn( + `./bin/postcss test/fixtures/a.css -o ${tmp()} -w --no-map`, + { shell: true } + ) + + cp.on('error', t.end) + cp.on('exit', (code) => { + t.is(code, 0) + t.end() + }) + cp.stdin.end() +}) From 1e7bf403f352caf67b45d48870e29900e6b9aa9e Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 17 Nov 2020 10:15:10 -0500 Subject: [PATCH 152/251] 8.3.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c74cd37..47faac6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 8.3.0 / 2020-11-17 + +- Exit on EOF/`^D` ([#358](https://github.com/postcss/postcss-cli/pull/358)) + # 8.2.0 / 2020-10-29 - Allow backslashes in paths for better Windows experence ([#355](https://github.com/postcss/postcss-cli/pull/355)) diff --git a/package.json b/package.json index 88a0b34..2c68a8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.2.0", + "version": "8.3.0", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 453aaec22c02064693ec8ee4d704a33ead27b97a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2020 14:49:18 -0500 Subject: [PATCH 153/251] Update dependency prettier to ~2.2.0 (#359) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c68a8f..d4415db 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^12.0.0", - "prettier": "~2.1.0", + "prettier": "~2.2.0", "sugarss": "^3.0.0", "uuid": "^8.0.0" }, From 4b9b66d5338b925ec6b52e2fd4bb1e5901038fbc Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 3 Dec 2020 12:54:07 -0500 Subject: [PATCH 154/251] Cast to string before passing input globs to slash If a number is passed as a positional argument, yargs interprets it as a JS Number, and slash tries to call .replace() on it, which fails. This ensures slash only gets strings passed to it. Refs https://github.com/postcss/postcss-cli/issues/360#issuecomment-738157557 --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 47a6e5a..0bab158 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,10 @@ Promise.resolve() } if (input && input.length) { - return globber(input.map(slash), { dot: argv.includeDotfiles }) + return globber( + input.map((i) => slash(String(i))), + { dot: argv.includeDotfiles } + ) } if (argv.replace || argv.dir) { From 96b6521da8b8fb0349a853e432be4e4e272da4a2 Mon Sep 17 00:00:00 2001 From: Kim Hallberg Date: Tue, 8 Dec 2020 16:56:45 +0100 Subject: [PATCH 155/251] Error when using unsupported PostCSS version (fix #361) (#362) --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 0bab158..ce117bb 100644 --- a/index.js +++ b/index.js @@ -56,6 +56,11 @@ if (argv.watch) { process.stdin.resume() } +/* istanbul ignore next */ +if (parseInt(postcss().version) < 8) { + error('Please install PostCSS 8 or above') +} + Promise.resolve() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { From f25d3de608f9e1990b3d6bc2edf2d6c008f7c8fb Mon Sep 17 00:00:00 2001 From: Kim Hallberg Date: Thu, 10 Dec 2020 20:55:48 +0100 Subject: [PATCH 156/251] Fix PostCSS CLI logo not loading (#363) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71db6e6..f96eab4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![chat][chat]][chat-url]
- + From 35545bdb384d0e75ffa4385de960968f4a6cd28d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Sat, 12 Dec 2020 09:56:19 -0500 Subject: [PATCH 157/251] 8.3.1 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47faac6..186942c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 8.3.1 / 2020-12-12 + +- Ensure paths are not interpreted as numbers ([#360](https://github.com/postcss/postcss-cli/issues/360)) +- Better errors for incorrect postcss version ([#361](https://github.com/postcss/postcss-cli/issues/361), [#362](https://github.com/postcss/postcss-cli/pull/362)) + # 8.3.0 / 2020-11-17 - Exit on EOF/`^D` ([#358](https://github.com/postcss/postcss-cli/pull/358)) diff --git a/package.json b/package.json index d4415db..b5b90e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.3.0", + "version": "8.3.1", "description": "CLI for PostCSS", "main": "index.js", "engines": { From 947665b58c079e0813becc67702f4749a92cb628 Mon Sep 17 00:00:00 2001 From: Shashikant Yadav Date: Tue, 19 Jan 2021 02:38:55 +0530 Subject: [PATCH 158/251] Fix grammatical mistake in README.md (#367) Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f96eab4..3f267bc 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Note that you **can not** set the `from` or `to` options for postcss in the conf ### Context -For more advanced usage it's recommend to to use a function in `postcss.config.js`, this gives you access to the CLI context to dynamically apply options and plugins **per file** +For more advanced usage, it's recommended to use a function in `postcss.config.js`; this gives you access to the CLI context to dynamically apply options and plugins **per file** | Name | Type | Default | Description | | :-------: | :--------: | :--------------------------------: | :------------------- | From 60b476de3eb4e79b6cd443ce6a400d96310f77a2 Mon Sep 17 00:00:00 2001 From: Ludovico Fischer <43557+ludofischer@users.noreply.github.com> Date: Mon, 18 Jan 2021 22:20:26 +0100 Subject: [PATCH 159/251] refactor: replace chalk with colorette (#365) Since postcss and postcss-reporter use colorette, getting rid of chalk in this package saves about 100KB when doing a `yarn install`. --- index.js | 10 +++++----- lib/args.js | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ce117bb..66ef2af 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const path = require('path') const prettyHrtime = require('pretty-hrtime') const stdin = require('get-stdin') const read = require('read-cache') -const chalk = require('chalk') +const { bold, dim, red, cyan, green } = require('colorette') const globber = require('globby') const slash = require('slash') const chokidar = require('chokidar') @@ -106,7 +106,7 @@ Promise.resolve() .then((results) => { if (argv.watch) { const printMessage = () => - printVerbose(chalk.dim('\nWaiting for file changes...')) + printVerbose(dim('\nWaiting for file changes...')) const watcher = chokidar.watch(input.concat(dependencies(results)), { usePolling: argv.poll, interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100, @@ -197,7 +197,7 @@ function css(css, file) { const time = process.hrtime() - printVerbose(chalk`{cyan Processing {bold ${relativePath}}...}`) + printVerbose(cyan(`Processing ${bold(relativePath)}...`)) return rc(ctx, argv.config) .then((config) => { @@ -245,7 +245,7 @@ function css(css, file) { return Promise.all(tasks).then(() => { const prettyTime = prettyHrtime(process.hrtime(time)) printVerbose( - chalk`{green Finished {bold ${relativePath}} in {bold ${prettyTime}}}` + green(`Finished ${bold(relativePath)} in ${bold(prettyTime)}`) ) const messages = result.warnings() @@ -288,7 +288,7 @@ function error(err) { if (argv.verbose) console.error() if (typeof err === 'string') { - console.error(chalk.red(err)) + console.error(red(err)) } else if (err.name === 'CssSyntaxError') { console.error(err.toString()) } else { diff --git a/lib/args.js b/lib/args.js index b027bb4..8b2dbf2 100644 --- a/lib/args.js +++ b/lib/args.js @@ -1,5 +1,5 @@ 'use strict' -const chalk = require('chalk') +const { bold, red } = require('colorette') const logo = ` /|\\ @@ -15,7 +15,7 @@ const logo = ` module.exports = require('yargs') .usage( - `${chalk.bold.red(logo)} + `${bold(red(logo))} Usage: $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] $0 ... [OPTIONS] --dir [--watch|-w] diff --git a/package.json b/package.json index b5b90e8..37222af 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "test": "nyc ava -v" }, "dependencies": { - "chalk": "^4.0.0", "chokidar": "^3.3.0", + "colorette": "^1.2.1", "dependency-graph": "^0.9.0", "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", From ab73f3652351a4a7f470aca185badc0a7af4e355 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 10 May 2021 15:18:57 -0400 Subject: [PATCH 160/251] chore(deps): update dependency prettier to ~2.3.0 (#380) * chore(deps): update dependency prettier to ~2.3.0 * prettier Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- lib/args.js | 6 ++---- package.json | 2 +- test/watch.js | 21 +++++++++------------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/args.js b/lib/args.js index 8b2dbf2..b2cd258 100644 --- a/lib/args.js +++ b/lib/args.js @@ -94,8 +94,7 @@ Usage: }, }) .option('base', { - desc: - 'Mirror the directory structure relative to this path in the output directory, for use with --dir', + desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir', type: 'string', implies: 'dir', }) @@ -105,8 +104,7 @@ Usage: type: 'boolean', }) .option('poll', { - desc: - 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', + desc: 'Use polling for file watching. Can optionally pass polling interval; default 100 ms', implies: 'watch', }) .option('config', { diff --git a/package.json b/package.json index 37222af..bab04ca 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^12.0.0", - "prettier": "~2.2.0", + "prettier": "~2.3.0", "sugarss": "^3.0.0", "uuid": "^8.0.0" }, diff --git a/test/watch.js b/test/watch.js index 4a51a11..a2377a8 100644 --- a/test/watch.js +++ b/test/watch.js @@ -64,10 +64,9 @@ testCb('--watch works', (t) => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected), - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { @@ -145,10 +144,9 @@ testCb('--watch postcss.config.js', (t) => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected), - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { @@ -216,10 +214,9 @@ testCb('--watch dependencies', (t) => { // Helper functions: function isEqual(p, expected) { - return Promise.all([ - read(path.join(dir, p)), - read(expected), - ]).then(([a, e]) => t.is(a, e)) + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) } function done(err) { From ee7d27a3445fc2919aa574ca22f96ed46fe3eeee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 18:34:20 -0400 Subject: [PATCH 161/251] Update dependency sugarss to v4 (#384) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bab04ca..bdc92ba 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "postcss": "^8.0.4", "postcss-import": "^12.0.0", "prettier": "~2.3.0", - "sugarss": "^3.0.0", + "sugarss": "^4.0.0", "uuid": "^8.0.0" }, "peerDependencies": { From f0e262ed484436a669d81b66424ef6017058950c Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Tue, 15 Jun 2021 00:56:42 +0100 Subject: [PATCH 162/251] Add support for `dir-dependency` messages (#383) * Add support for `dir-dependency` messages * Fix DependencyGraph test * update `if` statement for consistency * Deduplicate recompile files using a set * Add dependency tests --- index.js | 31 ++++++- lib/DependencyGraph.js | 15 +++- test/watch.js | 195 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 66ef2af..945611a 100644 --- a/index.js +++ b/index.js @@ -123,13 +123,17 @@ Promise.resolve() if (input.includes(file)) recompile.push(file) + const dependants = depGraph + .dependantsOf(file) + .concat(getAncestorDirs(file).flatMap(depGraph.dependantsOf)) + recompile = recompile.concat( - depGraph.dependantsOf(file).filter((file) => input.includes(file)) + dependants.filter((file) => input.includes(file)) ) if (!recompile.length) recompile = input - return files(recompile) + return files([...new Set(recompile)]) .then((results) => watcher.add(dependencies(results))) .then(printMessage) .catch(error) @@ -271,9 +275,17 @@ function dependencies(results) { if (result.messages <= 0) return result.messages - .filter((msg) => (msg.type === 'dependency' ? msg : '')) + .filter((msg) => + msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '' + ) .map(depGraph.add) - .forEach((dependency) => messages.push(dependency.file)) + .forEach((dependency) => { + if (dependency.type === 'dir-dependency') { + messages.push(dependency.dir) + } else { + messages.push(dependency.file) + } + }) }) return messages @@ -298,3 +310,14 @@ function error(err) { if (argv.watch) return process.exit(1) } + +// Input: '/imports/components/button.css' +// Output: ['/imports/components', '/imports', '/'] +function getAncestorDirs(fileOrDir) { + const { root } = path.parse(fileOrDir) + if (fileOrDir === root) { + return [] + } + const parentDir = path.dirname(fileOrDir) + return [parentDir, ...getAncestorDirs(parentDir)] +} diff --git a/lib/DependencyGraph.js b/lib/DependencyGraph.js index 03fae2e..c293cda 100644 --- a/lib/DependencyGraph.js +++ b/lib/DependencyGraph.js @@ -7,11 +7,18 @@ module.exports = function () { return { add(message) { message.parent = path.resolve(message.parent) - message.file = path.resolve(message.file) - graph.addNode(message.parent) - graph.addNode(message.file) - graph.addDependency(message.parent, message.file) + + if (message.type === 'dir-dependency') { + message.dir = path.resolve(message.dir) + graph.addNode(message.dir) + graph.addDependency(message.parent, message.dir) + } else { + message.file = path.resolve(message.file) + graph.addNode(message.file) + graph.addDependency(message.parent, message.file) + } + return message }, dependantsOf(node) { diff --git a/test/watch.js b/test/watch.js index a2377a8..5d2fdfe 100644 --- a/test/watch.js +++ b/test/watch.js @@ -299,3 +299,198 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { }) cp.stdin.end() }) + +testCb('--watch watches dependencies', (t) => { + let cp + + t.plan(2) + + ENV('', ['s.css', 'a.css', 'b.css']).then((dir) => { + fs.writeFile( + path.join(dir, 'postcss.config.js'), + ` + const fs = require('fs') + module.exports = { + plugins: [ + (root, result) => { + const file = '${path.resolve(dir, 'a.css')}' + result.messages.push({ + plugin: 'test', + type: 'dependency', + file, + parent: result.opts.from, + }) + root.nodes = [] + root.append(fs.readFileSync(file, 'utf8')) + return root + } + ] + } + ` + ) + .then(() => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + + // On the first output: + watcher.on('add', (p) => { + // Assert, then change the source file + if (p === 'output.css') { + isEqual(p, 'test/fixtures/a.css') + .then(() => read('test/fixtures/b.css')) + .then((css) => fs.writeFile(path.join(dir, 'a.css'), css)) + .catch(done) + } + }) + + // When the change is picked up: + watcher.on('change', (p) => { + if (p === 'output.css') { + isEqual(p, 'test/fixtures/b.css') + .then(() => done()) + .catch(done) + } + }) + + // Start postcss-cli: + watcher.on('ready', () => { + // Using exec() and quoting "*.css" to test watch's glob handling: + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} "s.css" -o output.css --no-map -w`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.on('exit', (code) => { + if (code) t.end(code) + }) + }) + + // Helper functions: + function isEqual(p, expected) { + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) + } + + function done(err) { + try { + cp.kill() + } catch {} + + t.end(err) + } + }) + .catch(t.end) + }) + + // Timeout: + setTimeout(() => t.end('test timeout'), 50000) +}) + +testCb('--watch watches directory dependencies', (t) => { + let cp + + t.plan(2) + + ENV('', ['s.css', 'base/level-1/b.css', 'base/level-1/level-2/a.css']).then( + (dir) => { + fs.writeFile( + path.join(dir, 'postcss.config.js'), + ` + const fs = require('fs') + module.exports = { + plugins: [ + (root, result) => { + result.messages.push({ + plugin: 'test', + type: 'dir-dependency', + dir: '${path.resolve(dir, 'base')}', + parent: result.opts.from, + }) + root.nodes = [] + root.append(fs.readFileSync('${path.resolve( + dir, + 'base/level-1/level-2/a.css' + )}', 'utf8')) + return root + } + ] + } + ` + ) + .then(() => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + + // On the first output: + watcher.on('add', (p) => { + // Assert, then change the source file + if (p === 'output.css') { + isEqual(p, 'test/fixtures/base/level-1/level-2/a.css') + .then(() => read('test/fixtures/base/level-1/b.css')) + .then((css) => + fs.writeFile( + path.join(dir, 'base/level-1/level-2/a.css'), + css + ) + ) + .catch(done) + } + }) + + // When the change is picked up: + watcher.on('change', (p) => { + if (p === 'output.css') { + isEqual(p, 'test/fixtures/base/level-1/b.css') + .then(() => done()) + .catch(done) + } + }) + + // Start postcss-cli: + watcher.on('ready', () => { + // Using exec() and quoting "*.css" to test watch's glob handling: + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} "s.css" -o output.css --no-map -w`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.on('exit', (code) => { + if (code) t.end(code) + }) + }) + + // Helper functions: + function isEqual(p, expected) { + return Promise.all([read(path.join(dir, p)), read(expected)]).then( + ([a, e]) => t.is(a, e) + ) + } + + function done(err) { + try { + cp.kill() + } catch {} + + t.end(err) + } + }) + .catch(t.end) + } + ) + + // Timeout: + setTimeout(() => t.end('test timeout'), 50000) +}) From 9a4ad25f3380a7b6e0e84ed6a95ae499ecefa4c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:04:19 -0400 Subject: [PATCH 163/251] Update dependency postcss-import to v14 (#364) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bdc92ba..dcc83ab 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "5.0.0", "nyc": "^15.0.0", "postcss": "^8.0.4", - "postcss-import": "^12.0.0", + "postcss-import": "^14.0.0", "prettier": "~2.3.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" From 4be419d4dab07b8982b4bdc04456c02880dbf667 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:05:05 -0400 Subject: [PATCH 164/251] Update dependency dependency-graph to ^0.11.0 (#368) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcc83ab..c566987 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "chokidar": "^3.3.0", "colorette": "^1.2.1", - "dependency-graph": "^0.9.0", + "dependency-graph": "^0.11.0", "fs-extra": "^9.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", From 71f7d29c9eb384c4cb7f3dc17d26462b39e74a66 Mon Sep 17 00:00:00 2001 From: Christoph Geschwind Date: Thu, 23 Sep 2021 15:48:06 +0200 Subject: [PATCH 165/251] Add support for glob matching when watching dir-dependency (#391) This extends #383 to pass glob information on to chokidar, with the intention of reducing outputs when unrelated files are modified --- index.js | 6 +- .../base/level-1/level-2/unrelated.md | 1 + test/watch.js | 117 ++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/base/level-1/level-2/unrelated.md diff --git a/index.js b/index.js index 945611a..21704bb 100644 --- a/index.js +++ b/index.js @@ -281,7 +281,11 @@ function dependencies(results) { .map(depGraph.add) .forEach((dependency) => { if (dependency.type === 'dir-dependency') { - messages.push(dependency.dir) + messages.push( + dependency.glob + ? path.join(dependency.dir, dependency.glob) + : dependency.dir + ) } else { messages.push(dependency.file) } diff --git a/test/fixtures/base/level-1/level-2/unrelated.md b/test/fixtures/base/level-1/level-2/unrelated.md new file mode 100644 index 0000000..e48c0e0 --- /dev/null +++ b/test/fixtures/base/level-1/level-2/unrelated.md @@ -0,0 +1 @@ +Editing this file should not trigger a rebuild. diff --git a/test/watch.js b/test/watch.js index 5d2fdfe..decff9d 100644 --- a/test/watch.js +++ b/test/watch.js @@ -494,3 +494,120 @@ testCb('--watch watches directory dependencies', (t) => { // Timeout: setTimeout(() => t.end('test timeout'), 50000) }) + +testCb( + '--watch applies glob on dir-dependency (and excludes non matching files)', + (t) => { + let cp + let modifying = null // one of "unrelated.md", "a.css" + + t.plan(1) + + ENV('', [ + 's.css', + 'base/level-1/b.css', + 'base/level-1/level-2/a.css', + 'base/level-1/level-2/unrelated.md', + ]).then((dir) => { + fs.writeFile( + path.join(dir, 'postcss.config.js'), + ` + const fs = require('fs') + module.exports = { + plugins: [ + (root, result) => { + result.messages.push({ + plugin: 'test', + type: 'dir-dependency', + dir: '${path.resolve(dir, 'base')}', + glob: '**/*.css', + parent: result.opts.from, + }) + root.nodes = [] + root.append(fs.readFileSync('${path.resolve( + dir, + 'base/level-1/level-2/a.css' + )}', 'utf8')) + return root + } + ] + } + ` + ) + .then(() => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + + // On the first output: + watcher.on('add', (p) => { + if (p === 'output.css') { + // Modify unwatched file, shouldn't trigger output + modifyUnwatched() + } + }) + + // When the change is picked up: + watcher.on('change', (p) => { + if (p === 'output.css') { + // Assert that change to output.css happened only after modifying the watched a.css + t.is( + modifying, + 'a.css', + `Unexpected change to ${p} after modifying ${modifying}` + ) + done() + } else if (p === 'base/level-1/level-2/unrelated.md') { + // Modify watched file next, should trigger output + setTimeout(modifyWatched, 250) + } + }) + + // Start postcss-cli: + watcher.on('ready', () => { + cp = exec( + `node ${path.resolve( + 'bin/postcss' + )} "s.css" -o output.css --no-map -w`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.on('exit', (code) => { + if (code) t.end(code) + }) + }) + + function modifyUnwatched() { + modifying = 'unrelated.md' + fs.writeFile( + path.join(dir, 'base/level-1/level-2/unrelated.md'), + 'Some modification' + ).catch(done) + } + + function modifyWatched() { + modifying = 'a.css' + fs.writeFile( + path.join(dir, 'base/level-1/level-2/a.css'), + 'a { color: hotpink }' + ).catch(done) + } + + function done(err) { + try { + cp.kill() + } catch {} + + t.end(err) + } + }) + .catch(t.end) + }) + + // Timeout: + setTimeout(() => t.end('test timeout'), 50000) + } +) From 19d1711c43f775036353e654ddc7916b156a8e4c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 23 Sep 2021 10:32:12 -0400 Subject: [PATCH 166/251] BREAKING: Officially remove config watching support Was already broken due to dependency upgrade, make it official --- test/watch.js | 80 --------------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/test/watch.js b/test/watch.js index decff9d..3bc8368 100644 --- a/test/watch.js +++ b/test/watch.js @@ -83,86 +83,6 @@ testCb('--watch works', (t) => { setTimeout(() => t.end('test timeout'), 50000) }) -testCb('--watch postcss.config.js', (t) => { - let cp - - t.plan(2) - - ENV('module.exports = {}', ['import.css', 'a.css']) - .then((dir) => { - // Init watcher: - const watcher = chokidar.watch('.', { - cwd: dir, - ignoreInitial: true, - awaitWriteFinish: true, - }) - - // On the first output: - watcher.on('add', (p) => { - // Assert, then change the source file - if (p === 'output.css') { - read(path.join(dir, p)) - .then((css) => { - t.is(css, '@import "./a.css";\n') - - return fs.writeFile( - path.join(dir, 'postcss.config.js'), - `module.exports = { - plugins: [ - require('postcss-import')() - ] - }` - ) - }) - .catch(done) - } - }) - - // When the change is picked up: - watcher.on('change', (p) => { - if (p === 'output.css') { - isEqual(p, 'test/fixtures/a.css') - .then(() => done()) - .catch(done) - } - }) - - // Start postcss-cli: - watcher.on('ready', () => { - cp = exec( - `node ${path.resolve( - 'bin/postcss' - )} import.css -o output.css -w --no-map`, - { cwd: dir } - ) - - cp.on('error', t.end) - cp.on('exit', (code) => { - if (code) t.end(code) - }) - }) - - // Helper functions: - function isEqual(p, expected) { - return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) - ) - } - - function done(err) { - try { - cp.kill() - } catch {} - - t.end(err) - } - }) - .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) -}) - testCb('--watch dependencies', (t) => { let cp From 5c1939db2d625058cf190585caa41e88a692885d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Thu, 23 Sep 2021 10:54:20 -0400 Subject: [PATCH 167/251] Add GitHub Actions CI (#394) * Add GitHub Actions CI; remove broken TravisCI * Remove old Greenkeeper badge --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ .travis.yml | 14 -------------- README.md | 5 ++--- 3 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..92c23af --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: Node.js CI +on: + push: + branches: master + pull_request: + +jobs: + test: + strategy: + matrix: + node: [10.x, 12.x, 14.x, 16.x] + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - run: git config --global core.autocrlf input + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - run: npm install + - run: npm run ci + - run: nyc report --reporter=text-lcov | coveralls + continue-on-error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 410129e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: node_js -git: - autocrlf: input -os: - - linux - - windows -node_js: - - node - - 12 - - 10 -script: - - npm run ci -after_success: - - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' diff --git a/README.md b/README.md index 3f267bc..9dc9a2d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ [![npm][npm]][npm-url] [![node][node]][node-url] -[![Greenkeeper badge](https://badges.greenkeeper.io/postcss/postcss-cli.svg)](https://greenkeeper.io/) [![tests][tests]][tests-url] [![cover][cover]][cover-url] [![chat][chat]][chat-url] @@ -142,8 +141,8 @@ module.exports = (ctx) => ({ [npm-url]: https://npmjs.com/package/postcss-cli [node]: https://img.shields.io/node/v/postcss-cli.svg [node-url]: https://nodejs.org/ -[tests]: http://img.shields.io/travis/postcss/postcss-cli/master.svg -[tests-url]: https://travis-ci.org/postcss/postcss-cli +[tests]: https://img.shields.io/github/workflow/status/postcss/postcss-cli/Node.js%20CI/master +[tests-url]: https://github.com/postcss/postcss-cli/actions?query=branch%3Amaster [cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg [cover-url]: https://coveralls.io/github/postcss/postcss-cli [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg From afc06494943b856f063b92754784fc87ae216e60 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 23 Sep 2021 19:39:32 -0400 Subject: [PATCH 168/251] BREAKING: Drop Node 10 support --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92c23af..5538d98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [10.x, 12.x, 14.x, 16.x] + node: [12.x, 14.x, 16.x] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/package.json b/package.json index c566987..ad1166d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "main": "index.js", "engines": { - "node": ">=10" + "node": ">=12" }, "bin": { "postcss": "./bin/postcss" From faf0f417e6a4de7a5c2a054dbe7bb7878a049c47 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:43:07 -0400 Subject: [PATCH 169/251] Update dependency prettier to ~2.4.0 (#397) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad1166d..46f3459 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.3.0", + "prettier": "~2.4.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From 9903e9e840b3e3822e6e1ec6c2bd3041b061bebd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:46:20 -0400 Subject: [PATCH 170/251] Update actions/setup-node action to v2 (#398) * Update actions/setup-node action to v2 * Edit Node version format Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5538d98..e0cb97d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,14 +8,14 @@ jobs: test: strategy: matrix: - node: [12.x, 14.x, 16.x] + node: [12, 14, 16] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} - run: npm install From 261aca2b29150c495bd152534cb58bacaf8ee399 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:47:37 -0400 Subject: [PATCH 171/251] Update dependency fs-extra to v10 (#381) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46f3459..e10eaa6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "chokidar": "^3.3.0", "colorette": "^1.2.1", "dependency-graph": "^0.11.0", - "fs-extra": "^9.0.0", + "fs-extra": "^10.0.0", "get-stdin": "^8.0.0", "globby": "^11.0.0", "postcss-load-config": "^3.0.0", From 793dca664f6d9d1b0fb5f03c7060281e611b1cd0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 20:08:30 -0400 Subject: [PATCH 172/251] Update dependency yargs to v17 (#382) * Update dependency yargs to v17 * Fix coercion * Add tests for coersion Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- lib/args.js | 12 ++++++------ package.json | 2 +- test/ext.js | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/args.js b/lib/args.js index b2cd258..e25dd0d 100644 --- a/lib/args.js +++ b/lib/args.js @@ -13,7 +13,7 @@ const logo = ` //_____||___*_________*___||_____// ` -module.exports = require('yargs') +const { argv } = require('yargs') .usage( `${bold(red(logo))} Usage: @@ -88,10 +88,6 @@ Usage: desc: 'Override the output file extension; for use with --dir', type: 'string', implies: 'dir', - coerce(ext) { - if (ext.indexOf('.') !== 0) return `.${ext}` - return ext - }, }) .option('base', { desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir', @@ -126,4 +122,8 @@ If there are multiple input files, the --dir or --replace option must be passed. Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. For more details, please see https://github.com/postcss/postcss-cli` - ).argv + ) + +if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}` + +module.exports = argv diff --git a/package.json b/package.json index e10eaa6..292af0d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "slash": "^3.0.0", - "yargs": "^16.0.0" + "yargs": "^17.0.0" }, "devDependencies": { "ava": "^3.1.0", diff --git a/test/ext.js b/test/ext.js index 7016782..c646630 100644 --- a/test/ext.js +++ b/test/ext.js @@ -23,3 +23,20 @@ test('--ext works', async (t) => { t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) }) + +test('--ext works with no leading dot', async (t) => { + const dir = tmp() + + const { error, stderr } = await cli([ + 'test/fixtures/a.sss', + '--parser', + 'sugarss', + '-d', + dir, + '--ext', + 'css', + ]) + t.falsy(error, stderr) + + t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) +}) From cd5d5df47fd988cbde7dfa7ad8063e3b111b2910 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Sep 2021 20:09:27 -0400 Subject: [PATCH 173/251] Update dependency colorette to v2 (#400) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 292af0d..a235e25 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "chokidar": "^3.3.0", - "colorette": "^1.2.1", + "colorette": "^2.0.0", "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^8.0.0", From 10f2603c8ffd24b19c62037e8f27ab97e46afcd2 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Fri, 24 Sep 2021 08:27:47 -0400 Subject: [PATCH 174/251] Port to ESM (#401) * Port to ESM * Port tests to ESM * Remove broken coveralls * Remove old nyc cleanup --- .eslintrc.yaml | 2 + .github/workflows/ci.yml | 2 - bin/postcss | 3 -- index.js | 90 ++++++++++++++++++++---------------- lib/DependencyGraph.js | 7 ++- lib/DependencyGraph.test.js | 7 ++- lib/args.js | 8 ++-- lib/getMapfile.js | 5 +- lib/getMapfile.test.js | 27 +++++++++++ package.json | 10 ++-- test/base.js | 11 ++--- test/cli.js | 9 ++-- test/config.js | 11 ++--- test/dir.js | 11 ++--- test/error.js | 13 +++--- test/ext.js | 11 ++--- test/fixtures/_bad-plugin.js | 1 - test/glob.js | 11 ++--- test/helpers/clean.js | 4 +- test/helpers/cli.js | 9 ++-- test/helpers/env.js | 13 +++--- test/helpers/read.js | 7 ++- test/helpers/tmp.js | 7 ++- test/map.js | 38 ++------------- test/misc.js | 5 +- test/parser.js | 9 ++-- test/replace.js | 13 +++--- test/stdin.js | 15 +++--- test/stdout.js | 13 +++--- test/stringifier.js | 9 ++-- test/syntax.js | 9 ++-- test/use.js | 9 ++-- test/watch.js | 44 ++++++++---------- 33 files changed, 210 insertions(+), 233 deletions(-) delete mode 100755 bin/postcss mode change 100644 => 100755 index.js create mode 100644 lib/getMapfile.test.js diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0473b0f..d838ba7 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,5 +1,7 @@ env: node: true +parserOptions: + sourceType: module extends: problems rules: no-console: off diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0cb97d..04cd7e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,5 +20,3 @@ jobs: node-version: ${{ matrix.node }} - run: npm install - run: npm run ci - - run: nyc report --reporter=text-lcov | coveralls - continue-on-error: true diff --git a/bin/postcss b/bin/postcss deleted file mode 100755 index d40abef..0000000 --- a/bin/postcss +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env node - -require('../') diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 21704bb..da83943 --- a/index.js +++ b/index.js @@ -1,23 +1,25 @@ -'use strict' - -const fs = require('fs-extra') -const path = require('path') - -const prettyHrtime = require('pretty-hrtime') -const stdin = require('get-stdin') -const read = require('read-cache') -const { bold, dim, red, cyan, green } = require('colorette') -const globber = require('globby') -const slash = require('slash') -const chokidar = require('chokidar') - -const postcss = require('postcss') -const postcssrc = require('postcss-load-config') -const reporter = require('postcss-reporter/lib/formatter')() - -const argv = require('./lib/args') -const createDependencyGraph = require('./lib/DependencyGraph') -const getMapfile = require('./lib/getMapfile') +#!/usr/bin/env node + +import fs from 'fs-extra' +import path from 'path' + +import prettyHrtime from 'pretty-hrtime' +import stdin from 'get-stdin' +import read from 'read-cache' +import { bold, dim, red, cyan, green } from 'colorette' +import globber from 'globby' +import slash from 'slash' +import chokidar from 'chokidar' + +import postcss from 'postcss' +import postcssrc from 'postcss-load-config' +import postcssReporter from 'postcss-reporter/lib/formatter.js' + +import argv from './lib/args.js' +import createDependencyGraph from './lib/DependencyGraph.js' +import getMapfile from './lib/getMapfile.js' + +const reporter = postcssReporter() const depGraph = createDependencyGraph() let input = argv._ @@ -25,25 +27,33 @@ const { dir, output } = argv if (argv.map) argv.map = { inline: false } -const cliConfig = { - options: { - map: argv.map !== undefined ? argv.map : { inline: true }, - parser: argv.parser ? require(argv.parser) : undefined, - syntax: argv.syntax ? require(argv.syntax) : undefined, - stringifier: argv.stringifier ? require(argv.stringifier) : undefined, - }, - plugins: argv.use - ? argv.use.map((plugin) => { - try { - return require(plugin)() - } catch (e) { - const msg = e.message || `Cannot find module '${plugin}'` - let prefix = msg.includes(plugin) ? '' : ` (${plugin})` - if (e.name && e.name !== 'Error') prefix += `: ${e.name}` - return error(`Plugin Error${prefix}: ${msg}'`) - } - }) - : [], +let cliConfig + +async function buildCliConfig() { + cliConfig = { + options: { + map: argv.map !== undefined ? argv.map : { inline: true }, + parser: argv.parser ? await import(argv.parser) : undefined, + syntax: argv.syntax ? await import(argv.syntax) : undefined, + stringifier: argv.stringifier + ? await import(argv.stringifier) + : undefined, + }, + plugins: argv.use + ? await Promise.all( + argv.use.map(async (plugin) => { + try { + return (await import(plugin)).default() + } catch (e) { + const msg = e.message || `Cannot find module '${plugin}'` + let prefix = msg.includes(plugin) ? '' : ` (${plugin})` + if (e.name && e.name !== 'Error') prefix += `: ${e.name}` + return error(`Plugin Error${prefix}: ${msg}'`) + } + }) + ) + : [], + } } let configFile @@ -61,7 +71,7 @@ if (parseInt(postcss().version) < 8) { error('Please install PostCSS 8 or above') } -Promise.resolve() +buildCliConfig() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { error('Cannot write to stdout in watch mode') diff --git a/lib/DependencyGraph.js b/lib/DependencyGraph.js index c293cda..efb7ac3 100644 --- a/lib/DependencyGraph.js +++ b/lib/DependencyGraph.js @@ -1,8 +1,7 @@ -'use strict' -const path = require('path') -const { DepGraph } = require('dependency-graph') +import path from 'path' +import { DepGraph } from 'dependency-graph' -module.exports = function () { +export default function createDependencyGraph() { const graph = new DepGraph() return { add(message) { diff --git a/lib/DependencyGraph.test.js b/lib/DependencyGraph.test.js index a0235ba..d54393c 100644 --- a/lib/DependencyGraph.test.js +++ b/lib/DependencyGraph.test.js @@ -1,7 +1,6 @@ -'use strict' -const test = require('ava') -const path = require('path') -const createDependencyGraph = require('./DependencyGraph.js') +import test from 'ava' +import path from 'path' +import createDependencyGraph from './DependencyGraph.js' function resolveArray(arr) { return arr.map((p) => path.resolve(p)) diff --git a/lib/args.js b/lib/args.js index e25dd0d..fb38937 100644 --- a/lib/args.js +++ b/lib/args.js @@ -1,5 +1,5 @@ -'use strict' -const { bold, red } = require('colorette') +import yargs from 'yargs' +import { bold, red } from 'colorette' const logo = ` /|\\ @@ -13,7 +13,7 @@ const logo = ` //_____||___*_________*___||_____// ` -const { argv } = require('yargs') +const { argv } = yargs(process.argv.slice(2)) .usage( `${bold(red(logo))} Usage: @@ -126,4 +126,4 @@ For more details, please see https://github.com/postcss/postcss-cli` if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}` -module.exports = argv +export default argv diff --git a/lib/getMapfile.js b/lib/getMapfile.js index 346fea7..e4d0c93 100644 --- a/lib/getMapfile.js +++ b/lib/getMapfile.js @@ -1,6 +1,5 @@ -'use strict' -const path = require('path') -module.exports = function getMapfile(options) { +import path from 'path' +export default function getMapfile(options) { if (options.map && typeof options.map.annotation === 'string') { return `${path.dirname(options.to)}/${options.map.annotation}` } diff --git a/lib/getMapfile.test.js b/lib/getMapfile.test.js new file mode 100644 index 0000000..becc460 --- /dev/null +++ b/lib/getMapfile.test.js @@ -0,0 +1,27 @@ +import test from 'ava' +import getMapfile from './getMapfile.js' + +test('mapFile path is properly resolved', async (t) => { + const paths = [ + { + input: { to: '/foo/bar.css/baz/index.css' }, + want: '/foo/bar.css/baz/index.css.map', + }, + { + input: { to: '/foo/bar.sss/baz/index.sss' }, + want: '/foo/bar.sss/baz/index.sss.map', + }, + { + input: { to: '/foo/bar.css/baz/bar.css' }, + want: '/foo/bar.css/baz/bar.css.map', + }, + { + input: { map: { annotation: 'foo.map' }, to: '/foo/bar.css/baz/bar.css' }, + want: '/foo/bar.css/baz/foo.map', + }, + ] + + for (const p of paths) { + t.is(getMapfile(p.input), p.want) + } +}) diff --git a/package.json b/package.json index a235e25..d06f1f3 100644 --- a/package.json +++ b/package.json @@ -2,20 +2,20 @@ "name": "postcss-cli", "version": "8.3.1", "description": "CLI for PostCSS", - "main": "index.js", + "type": "module", "engines": { "node": ">=12" }, "bin": { - "postcss": "./bin/postcss" + "postcss": "./index.js" }, "scripts": { - "ci": "eslint . && nyc ava -v && npm run prettier -- --list-different", + "ci": "eslint . && c8 ava -v && npm run prettier -- --list-different", "clean": "node test/helpers/clean.js", "prettier": "prettier --single-quote --no-semi \"**/*.{js,md}\"", "format": "npm run prettier -- --write && eslint . --fix", "pretest": "npm run clean && npm run format", - "test": "nyc ava -v" + "test": "c8 ava -v" }, "dependencies": { "chokidar": "^3.3.0", @@ -33,10 +33,10 @@ }, "devDependencies": { "ava": "^3.1.0", + "c8": "^7.9.0", "coveralls": "^3.0.0", "eslint": "^7.8.0", "eslint-config-problems": "5.0.0", - "nyc": "^15.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", "prettier": "~2.4.0", diff --git a/test/base.js b/test/base.js index 32eff27..496ca14 100644 --- a/test/base.js +++ b/test/base.js @@ -1,10 +1,9 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--base --dir works', async (t) => { const dir = tmp() diff --git a/test/cli.js b/test/cli.js index 0cdc7dc..3adab9b 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('works with defaults', async (t) => { const output = tmp('output.css') diff --git a/test/config.js b/test/config.js index b8b3de5..a4eb8c6 100644 --- a/test/config.js +++ b/test/config.js @@ -1,11 +1,10 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const ENV = require('./helpers/env.js') +import ENV from './helpers/env.js' -const cli = require('./helpers/cli.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import read from './helpers/read.js' test('supports common config', async (t) => { const env = `module.exports = { diff --git a/test/dir.js b/test/dir.js index ec4e60e..695f198 100644 --- a/test/dir.js +++ b/test/dir.js @@ -1,10 +1,9 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--dir works', async (t) => { const dir = tmp() diff --git a/test/error.js b/test/error.js index 38b972b..9901f47 100644 --- a/test/error.js +++ b/test/error.js @@ -1,8 +1,7 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const tmp = require('./helpers/tmp.js') -const cli = require('./helpers/cli.js') +import tmp from './helpers/tmp.js' +import cli from './helpers/cli.js' test('multiple input files && --output', (t) => { return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ error, code }) => { @@ -34,7 +33,7 @@ test('plugin not found', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /Plugin Error: Cannot find module 'postcss-plugin'/ + /Plugin Error: Cannot find package 'postcss-plugin'/ ) } ) @@ -44,12 +43,12 @@ test('plugin throws on require', (t) => { return cli([ 'test/fixtures/a.css', '-u', - './test/fixtures/_bad-plugin', + './test/fixtures/_bad-plugin.js', '-o', tmp(), ]).then(({ error, code }) => { t.is(code, 1, 'expected non-zero error code') - t.regex(error.toString(), /Plugin Error \(.*bad-plugin\): This fails/) + t.regex(error.toString(), /Plugin Error \(.*bad-plugin.js\): This fails/) }) }) diff --git a/test/ext.js b/test/ext.js index c646630..329f2c4 100644 --- a/test/ext.js +++ b/test/ext.js @@ -1,11 +1,10 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') +import fs from 'fs-extra' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' test('--ext works', async (t) => { const dir = tmp() diff --git a/test/fixtures/_bad-plugin.js b/test/fixtures/_bad-plugin.js index 7a4ffeb..2911e95 100644 --- a/test/fixtures/_bad-plugin.js +++ b/test/fixtures/_bad-plugin.js @@ -1,2 +1 @@ -'use strict' throw new Error('This fails') diff --git a/test/glob.js b/test/glob.js index e60b75a..33917ad 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,10 +1,9 @@ -'use strict' -const test = require('ava') -const path = require('path') +import test from 'ava' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('works with glob patterns', async (t) => { const output = tmp() diff --git a/test/helpers/clean.js b/test/helpers/clean.js index cabfc72..73bb191 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -1,10 +1,8 @@ -'use strict' -const fs = require('fs-extra') +import fs from 'fs-extra' Promise.all([ fs.emptyDir('./test/fixtures/.tmp/'), fs.remove('./coverage'), - fs.remove('./.nyc_output'), ]).catch((err) => { console.error(err) process.exit(1) diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 64b9154..565d3ff 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -1,11 +1,10 @@ -'use strict' -const path = require('path') -const { exec } = require('child_process') +import path from 'path' +import { exec } from 'child_process' -module.exports = function (args, cwd) { +export default function (args, cwd) { return new Promise((resolve) => { exec( - `node ${path.resolve('bin/postcss')} ${args.join(' ')}`, + `node ${path.resolve('index.js')} ${args.join(' ')}`, { cwd }, (error, stdout, stderr) => { resolve({ diff --git a/test/helpers/env.js b/test/helpers/env.js index b389370..e6f48c2 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,11 +1,10 @@ -'use strict' -const fs = require('fs-extra') -const path = require('path') -const globby = require('globby') +import fs from 'fs-extra' +import path from 'path' +import globby from 'globby' -const tmp = require('./tmp.js') +import tmp from './tmp.js' -module.exports = function (config, fixtures) { +export default function (config, fixtures) { fixtures = fixtures || '**/*' const dir = tmp() @@ -15,6 +14,6 @@ module.exports = function (config, fixtures) { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) }), - fs.outputFile(path.join(dir, 'postcss.config.js'), config), + fs.outputFile(path.join(dir, 'postcss.config.cjs'), config), ]).then(() => dir) } diff --git a/test/helpers/read.js b/test/helpers/read.js index 88b6421..1dbe451 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,8 +1,7 @@ -'use strict' -const { readFile } = require('fs-extra') +import fs from 'fs-extra' -module.exports = function (path) { - return readFile(path, 'utf8').then( +export default function (path) { + return fs.readFile(path, 'utf8').then( (content) => content.replace(/\r\n/g, '\n') // normalize line endings on Windows ) } diff --git a/test/helpers/tmp.js b/test/helpers/tmp.js index a23fa35..bfa1369 100644 --- a/test/helpers/tmp.js +++ b/test/helpers/tmp.js @@ -1,8 +1,7 @@ -'use strict' -const path = require('path') -const { v4: uuid } = require('uuid') +import path from 'path' +import { v4 as uuid } from 'uuid' -module.exports = function (ext) { +export default function (ext) { ext = ext || '' return path.join('test/fixtures/.tmp', uuid(), ext) diff --git a/test/map.js b/test/map.js index 04f90fd..4783010 100644 --- a/test/map.js +++ b/test/map.js @@ -1,12 +1,9 @@ -'use strict' -const test = require('ava') -const fs = require('fs-extra') +import test from 'ava' +import fs from 'fs-extra' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') - -const getMapfile = require('../lib/getMapfile') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('inline maps are generated by default', async (t) => { const output = tmp('output.css') @@ -56,28 +53,3 @@ test('--no-map disables internal sourcemaps', async (t) => { t.notRegex(await read(output), /\/*# sourceMappingURL=/) }) - -test('mapFile path is property resolved', async (t) => { - const paths = [ - { - input: { to: '/foo/bar.css/baz/index.css' }, - want: '/foo/bar.css/baz/index.css.map', - }, - { - input: { to: '/foo/bar.sss/baz/index.sss' }, - want: '/foo/bar.sss/baz/index.sss.map', - }, - { - input: { to: '/foo/bar.css/baz/bar.css' }, - want: '/foo/bar.css/baz/bar.css.map', - }, - { - input: { map: { annotation: 'foo.map' }, to: '/foo/bar.css/baz/bar.css' }, - want: '/foo/bar.css/baz/foo.map', - }, - ] - - for (const p of paths) { - t.is(getMapfile(p.input), p.want) - } -}) diff --git a/test/misc.js b/test/misc.js index 9240e32..812b6d0 100644 --- a/test/misc.js +++ b/test/misc.js @@ -1,7 +1,6 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') +import cli from './helpers/cli.js' test('--help', async (t) => { const help = await cli(['--help']) diff --git a/test/parser.js b/test/parser.js index 1ac9805..689d9b7 100644 --- a/test/parser.js +++ b/test/parser.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--parser works', async (t) => { const output = tmp('output.css') diff --git a/test/replace.js b/test/replace.js index f2712a2..dd24b98 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,12 +1,11 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') +import fs from 'fs-extra' +import path from 'path' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--replace works', async (t) => { const dir = tmp() diff --git a/test/stdin.js b/test/stdin.js index 8709a94..9fb0679 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -1,18 +1,17 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') -const { exec } = require('child_process') +import fs from 'fs-extra' +import path from 'path' +import { exec } from 'child_process' -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test.cb('reads from stdin', (t) => { const output = tmp('output.css') const cp = exec( - `node ${path.resolve('bin/postcss')} -o ${output} --no-map`, + `node ${path.resolve('index.js')} -o ${output} --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) diff --git a/test/stdout.js b/test/stdout.js index 8bd5d7b..68b6b4b 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -1,16 +1,15 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') -const { exec } = require('child_process') +import fs from 'fs-extra' +import path from 'path' +import { exec } from 'child_process' -const read = require('./helpers/read.js') +import read from './helpers/read.js' test.cb('writes to stdout', (t) => { const cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} --parser sugarss -u postcss-import --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) diff --git a/test/stringifier.js b/test/stringifier.js index db3ef28..69adaff 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--stringifier works', async (t) => { const output = tmp('output.sss') diff --git a/test/syntax.js b/test/syntax.js index c4295f9..b17e1fd 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--syntax works', async (t) => { const output = tmp('output.sss') diff --git a/test/use.js b/test/use.js index 25400f6..c35d6cd 100644 --- a/test/use.js +++ b/test/use.js @@ -1,9 +1,8 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const cli = require('./helpers/cli.js') -const tmp = require('./helpers/tmp.js') -const read = require('./helpers/read.js') +import cli from './helpers/cli.js' +import tmp from './helpers/tmp.js' +import read from './helpers/read.js' test('--use works', async (t) => { const output = tmp('i.css') diff --git a/test/watch.js b/test/watch.js index 3bc8368..b38b81d 100644 --- a/test/watch.js +++ b/test/watch.js @@ -1,14 +1,13 @@ -'use strict' -const test = require('ava') +import test from 'ava' -const fs = require('fs-extra') -const path = require('path') -const { exec, spawn } = require('child_process') -const chokidar = require('chokidar') +import fs from 'fs-extra' +import path from 'path' +import { exec, spawn } from 'child_process' +import chokidar from 'chokidar' -const ENV = require('./helpers/env.js') -const read = require('./helpers/read.js') -const tmp = require('./helpers/tmp.js') +import ENV from './helpers/env.js' +import read from './helpers/read.js' +import tmp from './helpers/tmp.js' // XXX: All the tests in this file are skipped on the CI; too flacky there const testCb = process.env.CI ? test.cb.skip : test.cb @@ -51,9 +50,7 @@ testCb('--watch works', (t) => { watcher.on('ready', () => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( - `node ${path.resolve( - 'bin/postcss' - )} "*.css" -o output.css --no-map -w`, + `node ${path.resolve('index.js')} "*.css" -o output.css --no-map -w`, { cwd: dir } ) cp.on('error', t.end) @@ -121,7 +118,7 @@ testCb('--watch dependencies', (t) => { watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} import.css -o output.css -u postcss-import -w --no-map`, { cwd: dir } ) @@ -172,7 +169,7 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => { let killed = false const cp = exec( - `node ${path.resolve('bin/postcss')} a.css -o output.css -w --no-map`, + `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, { cwd: dir } ) cp.on('error', t.end) @@ -207,10 +204,9 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => { testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.plan(1) - const cp = spawn( - `./bin/postcss test/fixtures/a.css -o ${tmp()} -w --no-map`, - { shell: true } - ) + const cp = spawn(`./index.js test/fixtures/a.css -o ${tmp()} -w --no-map`, { + shell: true, + }) cp.on('error', t.end) cp.on('exit', (code) => { @@ -227,7 +223,7 @@ testCb('--watch watches dependencies', (t) => { ENV('', ['s.css', 'a.css', 'b.css']).then((dir) => { fs.writeFile( - path.join(dir, 'postcss.config.js'), + path.join(dir, 'postcss.config.cjs'), ` const fs = require('fs') module.exports = { @@ -281,7 +277,7 @@ testCb('--watch watches dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} "s.css" -o output.css --no-map -w`, { cwd: dir } ) @@ -321,7 +317,7 @@ testCb('--watch watches directory dependencies', (t) => { ENV('', ['s.css', 'base/level-1/b.css', 'base/level-1/level-2/a.css']).then( (dir) => { fs.writeFile( - path.join(dir, 'postcss.config.js'), + path.join(dir, 'postcss.config.cjs'), ` const fs = require('fs') module.exports = { @@ -382,7 +378,7 @@ testCb('--watch watches directory dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} "s.css" -o output.css --no-map -w`, { cwd: dir } ) @@ -430,7 +426,7 @@ testCb( 'base/level-1/level-2/unrelated.md', ]).then((dir) => { fs.writeFile( - path.join(dir, 'postcss.config.js'), + path.join(dir, 'postcss.config.cjs'), ` const fs = require('fs') module.exports = { @@ -490,7 +486,7 @@ testCb( watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'bin/postcss' + 'index.js' )} "s.css" -o output.css --no-map -w`, { cwd: dir } ) From a864c5bd3c530c35a801b4e178fe0c1aef202dfa Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 24 Sep 2021 09:26:28 -0400 Subject: [PATCH 175/251] Remove broken logo printing --- lib/args.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/args.js b/lib/args.js index fb38937..35f0e83 100644 --- a/lib/args.js +++ b/lib/args.js @@ -1,22 +1,8 @@ import yargs from 'yargs' -import { bold, red } from 'colorette' - -const logo = ` - /|\\ - // // - // // - //___*___*___// - //--*---------*--// - /|| * * ||/ - // ||* *|| // - // || * * || // - //_____||___*_________*___||_____// -` const { argv } = yargs(process.argv.slice(2)) .usage( - `${bold(red(logo))} -Usage: + `Usage: $0 [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] $0 ... [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] From c9258b19610b8bce441487d01f20bb280d35c93f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 09:27:42 -0400 Subject: [PATCH 176/251] Update dependency get-stdin to v9 (#376) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d06f1f3..27a1859 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "colorette": "^2.0.0", "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", - "get-stdin": "^8.0.0", + "get-stdin": "^9.0.0", "globby": "^11.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", From 9d770031cebe41921e252a5b5ad9d1d490b833b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 09:28:31 -0400 Subject: [PATCH 177/251] Update dependency slash to v4 (#377) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27a1859..1b98b11 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "slash": "^3.0.0", + "slash": "^4.0.0", "yargs": "^17.0.0" }, "devDependencies": { From ace2a31e173688f096c8c3ba0383e7493f22d913 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 09:32:56 -0400 Subject: [PATCH 178/251] Update dependency globby to v12 (#386) * Update dependency globby to v12 * Use named imports Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- index.js | 4 ++-- package.json | 2 +- test/helpers/env.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index da83943..5e3528e 100755 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ import prettyHrtime from 'pretty-hrtime' import stdin from 'get-stdin' import read from 'read-cache' import { bold, dim, red, cyan, green } from 'colorette' -import globber from 'globby' +import { globby } from 'globby' import slash from 'slash' import chokidar from 'chokidar' @@ -78,7 +78,7 @@ buildCliConfig() } if (input && input.length) { - return globber( + return globby( input.map((i) => slash(String(i))), { dot: argv.includeDotfiles } ) diff --git a/package.json b/package.json index 1b98b11..c679738 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", - "globby": "^11.0.0", + "globby": "^12.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", diff --git a/test/helpers/env.js b/test/helpers/env.js index e6f48c2..7ec542e 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,6 +1,6 @@ import fs from 'fs-extra' import path from 'path' -import globby from 'globby' +import { globby } from 'globby' import tmp from './tmp.js' From 201205ce210f2d05ab6caf094e574b3319ec38cf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Fri, 24 Sep 2021 10:01:02 -0400 Subject: [PATCH 179/251] Run watch tests on Linux CI (#396) --- test/watch.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/watch.js b/test/watch.js index b38b81d..8d47ec7 100644 --- a/test/watch.js +++ b/test/watch.js @@ -9,8 +9,9 @@ import ENV from './helpers/env.js' import read from './helpers/read.js' import tmp from './helpers/tmp.js' -// XXX: All the tests in this file are skipped on the CI; too flacky there -const testCb = process.env.CI ? test.cb.skip : test.cb +// XXX: All the tests in this file are skipped on the Windows CI; too flacky there +const testCb = + process.env.CI && process.platform === 'win32' ? test.cb.skip : test.cb testCb('--watch works', (t) => { let cp From b90bd7f2e3ec08db50157d11fe83e24f068b9abf Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 24 Sep 2021 12:38:50 -0400 Subject: [PATCH 180/251] 9.0.0 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 186942c..922fa07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 9.0.0 / 2021-09-24 + +- **BREAKING:** Require Node.js v12+ +- **BREAKING:** Must specify full file path, including `.js` extension, when loading local plugins with `--use` ([#401](https://github.com/postcss/postcss-cli/pull/401)) +- **BREAKING:** Officially remove support for watching postcss config (was already broken in previous releases) +- Add support for `dir-dependency` messages ([#383](https://github.com/postcss/postcss-cli/pull/383), [#391](https://github.com/postcss/postcss-cli/pull/391)) +- Update deps + # 8.3.1 / 2020-12-12 - Ensure paths are not interpreted as numbers ([#360](https://github.com/postcss/postcss-cli/issues/360)) diff --git a/package.json b/package.json index c679738..8b424f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "8.3.1", + "version": "9.0.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 96a7dc67f1ea8f26f1be0261e273dc1c8b925728 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:26:22 -0400 Subject: [PATCH 181/251] Remove bin/ from `files` in package.json h/t https://github.com/postcss/postcss-cli/issues/403#issuecomment-928207662 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 8b424f2..7eaaad8 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "postcss": "^8.0.0" }, "files": [ - "bin", "index.js", "lib", "!*.test.js" From 49db8224ce9eed7b18a76814e912c0cb5469278f Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:35:23 -0400 Subject: [PATCH 182/251] Use nanocolors --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5e3528e..76310dd 100755 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ import path from 'path' import prettyHrtime from 'pretty-hrtime' import stdin from 'get-stdin' import read from 'read-cache' -import { bold, dim, red, cyan, green } from 'colorette' +import { bold, dim, red, cyan, green } from 'nanocolors' import { globby } from 'globby' import slash from 'slash' import chokidar from 'chokidar' diff --git a/package.json b/package.json index 7eaaad8..1b011a2 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ }, "dependencies": { "chokidar": "^3.3.0", - "colorette": "^2.0.0", "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", "globby": "^12.0.0", + "nanocolors": "^0.2.11", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", From 31436423d83f77965442dcf1c421a5d90a56dfc3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:35:01 -0400 Subject: [PATCH 183/251] Actually exit when writing to stdout in watch mode --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 76310dd..45959ac 100755 --- a/index.js +++ b/index.js @@ -75,6 +75,8 @@ buildCliConfig() .then(() => { if (argv.watch && !(argv.output || argv.replace || argv.dir)) { error('Cannot write to stdout in watch mode') + // Need to explicitly exit here, since error() doesn't exit in watch mode + process.exit(1) } if (input && input.length) { From 392c4f51f6ed11d5fdb857e486005ab29b09b41c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:42:17 -0400 Subject: [PATCH 184/251] 9.0.1 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 922fa07..6c60b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 9.0.1 / 2021-09-28 + +- Actually exit with error when attempting to stdout in watch mode +- Remove `bin/` from `files` in package.json + # 9.0.0 / 2021-09-24 - **BREAKING:** Require Node.js v12+ diff --git a/package.json b/package.json index 1b011a2..da94c28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.0.0", + "version": "9.0.1", "description": "CLI for PostCSS", "type": "module", "engines": { From 66b7c80cba7b9b638dc7c1019929bb07dd569670 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 28 Sep 2021 10:44:25 -0400 Subject: [PATCH 185/251] Exclude test files from npm package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da94c28..b8d8a1f 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "files": [ "index.js", "lib", - "!*.test.js" + "!**/*.test.js" ], "keywords": [ "cli", From ecf2bee0c74d4d2ad20b955d173d3f7dd6ad7460 Mon Sep 17 00:00:00 2001 From: Ludovico Fischer <43557+ludofischer@users.noreply.github.com> Date: Thu, 4 Nov 2021 23:54:16 +0100 Subject: [PATCH 186/251] chore: use picocolors for colored terminal output (#409) Replace deprecated nanocolors with picocolors. --- index.js | 12 +++++++----- package.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 45959ac..a5286f7 100755 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ import path from 'path' import prettyHrtime from 'pretty-hrtime' import stdin from 'get-stdin' import read from 'read-cache' -import { bold, dim, red, cyan, green } from 'nanocolors' +import pc from 'picocolors' import { globby } from 'globby' import slash from 'slash' import chokidar from 'chokidar' @@ -118,7 +118,7 @@ buildCliConfig() .then((results) => { if (argv.watch) { const printMessage = () => - printVerbose(dim('\nWaiting for file changes...')) + printVerbose(pc.dim('\nWaiting for file changes...')) const watcher = chokidar.watch(input.concat(dependencies(results)), { usePolling: argv.poll, interval: argv.poll && typeof argv.poll === 'number' ? argv.poll : 100, @@ -213,7 +213,7 @@ function css(css, file) { const time = process.hrtime() - printVerbose(cyan(`Processing ${bold(relativePath)}...`)) + printVerbose(pc.cyan(`Processing ${pc.bold(relativePath)}...`)) return rc(ctx, argv.config) .then((config) => { @@ -261,7 +261,9 @@ function css(css, file) { return Promise.all(tasks).then(() => { const prettyTime = prettyHrtime(process.hrtime(time)) printVerbose( - green(`Finished ${bold(relativePath)} in ${bold(prettyTime)}`) + pc.green( + `Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}` + ) ) const messages = result.warnings() @@ -316,7 +318,7 @@ function error(err) { if (argv.verbose) console.error() if (typeof err === 'string') { - console.error(red(err)) + console.error(pc.red(err)) } else if (err.name === 'CssSyntaxError') { console.error(err.toString()) } else { diff --git a/package.json b/package.json index b8d8a1f..14e5f8c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", "globby": "^12.0.0", - "nanocolors": "^0.2.11", + "picocolors": "^1.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", From 538b6f52442fba732190fff93ab8d977be3b667a Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 4 Nov 2021 18:58:19 -0400 Subject: [PATCH 187/251] 9.0.2 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c60b58..0c21c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 9.0.2 / 2021-11-04 + +- Switch to picocolors ([#409](https://github.com/postcss/postcss-cli/pull/409)) +- Remove test files from npm package + # 9.0.1 / 2021-09-28 - Actually exit with error when attempting to stdout in watch mode diff --git a/package.json b/package.json index 14e5f8c..d8eef3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.0.1", + "version": "9.0.2", "description": "CLI for PostCSS", "type": "module", "engines": { From 018496898dc26281fc336738d96dd2c444db1655 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Nov 2021 12:47:03 -0500 Subject: [PATCH 188/251] Update eslint & eslint-config-problems (#413) * Update dependency eslint-config-problems to v6 * Bump eslint version Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8eef3b..70325b5 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ "ava": "^3.1.0", "c8": "^7.9.0", "coveralls": "^3.0.0", - "eslint": "^7.8.0", - "eslint-config-problems": "5.0.0", + "eslint": "^8.2.0", + "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", "prettier": "~2.4.0", From 6256aa711fa2c691a47d5b16528d6b88926a09d9 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:09:48 -0500 Subject: [PATCH 189/251] Refactor watch tests (#416) --- test/watch.js | 109 ++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 61 deletions(-) diff --git a/test/watch.js b/test/watch.js index 8d47ec7..af69eb4 100644 --- a/test/watch.js +++ b/test/watch.js @@ -76,9 +76,6 @@ testCb('--watch works', (t) => { } }) .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) testCb('--watch dependencies', (t) => { @@ -145,62 +142,61 @@ testCb('--watch dependencies', (t) => { } }) .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) -testCb("--watch doesn't exit on CssSyntaxError", (t) => { - t.plan(0) +// Doesn't work on CI for some reason +;(process.env.CI ? test.cb.skip : test.cb)( + "--watch doesn't exit on CssSyntaxError", + (t) => { + t.plan(0) - ENV('', ['a.css']) - .then((dir) => { - // Init watcher: - const watcher = chokidar.watch('.', { - cwd: dir, - ignoreInitial: true, - awaitWriteFinish: true, - }) - watcher.on('add', (p) => { - if (p === 'output.css') { - // Change to invalid CSS - fs.writeFile(path.join(dir, 'a.css'), '.a { color: red').catch(done) - } - }) + ENV('', ['a.css']) + .then((dir) => { + // Init watcher: + const watcher = chokidar.watch('.', { + cwd: dir, + ignoreInitial: true, + awaitWriteFinish: true, + }) + watcher.on('add', (p) => { + if (p === 'output.css') { + // Change to invalid CSS + fs.writeFile(path.join(dir, 'a.css'), '.a { color: red').catch(done) + } + }) - let killed = false - const cp = exec( - `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, - { cwd: dir } - ) - cp.on('error', t.end) - cp.stderr.on('data', (chunk) => { - // When error message is printed, kill the process after a timeout - if (~chunk.indexOf('Unclosed block')) { - setTimeout(() => { - killed = true + let killed = false + const cp = exec( + `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, + { cwd: dir } + ) + cp.on('error', t.end) + cp.stderr.on('data', (chunk) => { + // When error message is printed, kill the process after a timeout + if (~chunk.indexOf('Unclosed block')) { + setTimeout(() => { + killed = true + cp.kill() + }, 1000) + } + }) + cp.on('exit', (code) => { + if (!killed) + return t.end(`Should not exit (exited with code ${code})`) + done() + }) + + function done(err) { + try { cp.kill() - }, 1000) + } catch {} + + t.end(err) } }) - cp.on('exit', (code) => { - if (!killed) return t.end(`Should not exit (exited with code ${code})`) - done() - }) - - function done(err) { - try { - cp.kill() - } catch {} - - t.end(err) - } - }) - .catch(t.end) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) -}) + .catch(t.end) + } +) testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.plan(1) @@ -305,9 +301,6 @@ testCb('--watch watches dependencies', (t) => { }) .catch(t.end) }) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) testCb('--watch watches directory dependencies', (t) => { @@ -407,9 +400,6 @@ testCb('--watch watches directory dependencies', (t) => { .catch(t.end) } ) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) }) testCb( @@ -523,8 +513,5 @@ testCb( }) .catch(t.end) }) - - // Timeout: - setTimeout(() => t.end('test timeout'), 50000) } ) From c7cc0bb55eb2fd1f3280967cb669f6ac414a068b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:18:28 -0500 Subject: [PATCH 190/251] Update dependency prettier to ~2.5.0 (#414) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70325b5..8e1bb4d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.4.0", + "prettier": "~2.5.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From b06fa800bbcf1875aa89b4fcd8afbde5677e6638 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 10 Dec 2021 13:46:36 -0700 Subject: [PATCH 191/251] feat: only save files if they are unchanged (#417) Closes #320 --- index.js | 11 +++++++++-- test/fixtures/unchanged-input.css | 3 +++ test/fixtures/unchanged-output.css | 5 +++++ test/unchanged.js | 17 +++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/unchanged-input.css create mode 100644 test/fixtures/unchanged-output.css create mode 100644 test/unchanged.js diff --git a/index.js b/index.js index a5286f7..615638c 100755 --- a/index.js +++ b/index.js @@ -250,11 +250,11 @@ function css(css, file) { const tasks = [] if (options.to) { - tasks.push(fs.outputFile(options.to, result.css)) + tasks.push(outputFile(options.to, result.css)) if (result.map) { const mapfile = getMapfile(options) - tasks.push(fs.outputFile(mapfile, result.map.toString())) + tasks.push(outputFile(mapfile, result.map.toString())) } } else process.stdout.write(result.css, 'utf8') @@ -278,6 +278,13 @@ function css(css, file) { .catch((err) => { throw err }) + + async function outputFile(file, string) { + const fileExists = await fs.pathExists(file) + const currentValue = fileExists ? await fs.readFile(file, 'utf8') : null + if (currentValue === string) return + return fs.outputFile(file, string) + } } function dependencies(results) { diff --git a/test/fixtures/unchanged-input.css b/test/fixtures/unchanged-input.css new file mode 100644 index 0000000..60f1eab --- /dev/null +++ b/test/fixtures/unchanged-input.css @@ -0,0 +1,3 @@ +body { + color: red; +} diff --git a/test/fixtures/unchanged-output.css b/test/fixtures/unchanged-output.css new file mode 100644 index 0000000..6521159 --- /dev/null +++ b/test/fixtures/unchanged-output.css @@ -0,0 +1,5 @@ +body { + color: red; +} + +/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInVuY2hhbmdlZC1pbnB1dC5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEiLCJmaWxlIjoidW5jaGFuZ2VkLW91dHB1dC5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJib2R5IHtcbiAgY29sb3I6IHJlZDtcbn1cbiJdfQ== */ \ No newline at end of file diff --git a/test/unchanged.js b/test/unchanged.js new file mode 100644 index 0000000..4598530 --- /dev/null +++ b/test/unchanged.js @@ -0,0 +1,17 @@ +import fs from 'fs-extra' +import test from 'ava' + +import cli from './helpers/cli.js' + +test('files are not saved if the contents are the same', async (t) => { + const input = 'test/fixtures/unchanged-input.css' + const output = 'test/fixtures/unchanged-output.css' + const intialStat = await fs.stat(output) + + const { error, stderr } = await cli([input, '-o', output]) + + t.falsy(error, stderr) + + const finalStat = await fs.stat(output) + t.is(finalStat.mtimeMs, intialStat.mtimeMs) +}) From c9f69057ddefd4595faa14b847d57f148211ce62 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 10 Dec 2021 15:49:39 -0500 Subject: [PATCH 192/251] 9.1.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c21c2a..d63af2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 9.1.0 / 2021-12-10 + +- Don't write to files if they're unchanged ([#320](https://github.com/postcss/postcss-cli/issues/320), [#417](https://github.com/postcss/postcss-cli/pull/417)) + # 9.0.2 / 2021-11-04 - Switch to picocolors ([#409](https://github.com/postcss/postcss-cli/pull/409)) diff --git a/package.json b/package.json index 8e1bb4d..141c899 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.0.2", + "version": "9.1.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 07369934ed260e096d7b3b20ffe9babffdb03db8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 14:24:49 -0500 Subject: [PATCH 193/251] Update dependency globby to v13 (#427) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 141c899..8ebcbcb 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependency-graph": "^0.11.0", "fs-extra": "^10.0.0", "get-stdin": "^9.0.0", - "globby": "^12.0.0", + "globby": "^13.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^3.0.0", "postcss-reporter": "^7.0.0", From 62d9505a2315e60007a80665ee7e54581fd91bf7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Feb 2022 10:34:56 -0500 Subject: [PATCH 194/251] Update actions/setup-node action to v3 (#429) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04cd7e1..41328fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - run: git config --global core.autocrlf input - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - run: npm install From 006288238ac1cb4941b681045067682c30881fa9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:47:09 -0500 Subject: [PATCH 195/251] Update actions/checkout action to v3 (#430) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41328fb..d814851 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v3 with: From 82548cac9e385a4e3cb817fe6a67924c60710a66 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 16 Mar 2022 10:58:26 -0400 Subject: [PATCH 196/251] Update dependency prettier to ~2.6.0 (#431) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ebcbcb..8055e1b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.5.0", + "prettier": "~2.6.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From eb45758928b6146e91c9ec86a00dd6235c357cf2 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:39:52 -0400 Subject: [PATCH 197/251] BREAKING: Drop Node 12 support (#438) --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d814851..45349ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [12, 14, 16] + node: [14, 16, 18] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/package.json b/package.json index 8055e1b..e82cd9f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "type": "module", "engines": { - "node": ">=12" + "node": ">=14" }, "bin": { "postcss": "./index.js" From e1751d05e674d135b5f97db7bc666cc855525d3c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:42:33 -0400 Subject: [PATCH 198/251] Update dependency prettier to ~2.7.0 (#436) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e82cd9f..b55467c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", "postcss-import": "^14.0.0", - "prettier": "~2.6.0", + "prettier": "~2.7.0", "sugarss": "^4.0.0", "uuid": "^8.0.0" }, From 7a8d21e99bbd94b0e684a5d9b0ece30951b7f0be Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:47:07 -0400 Subject: [PATCH 199/251] Update dependency postcss-load-config to v4 (#437) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b55467c..920100e 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "get-stdin": "^9.0.0", "globby": "^13.0.0", "picocolors": "^1.0.0", - "postcss-load-config": "^3.0.0", + "postcss-load-config": "^4.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From a1e547e697a4eaae795a9666ea9220aad1a3b1d3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 29 Jun 2022 21:32:08 -0400 Subject: [PATCH 200/251] Fix watch test --- test/watch.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/watch.js b/test/watch.js index af69eb4..4cd5391 100644 --- a/test/watch.js +++ b/test/watch.js @@ -167,7 +167,9 @@ testCb('--watch dependencies', (t) => { let killed = false const cp = exec( - `node ${path.resolve('index.js')} a.css -o output.css -w --no-map`, + `node ${path.resolve( + 'index.js' + )} a.css -o output.css -u postcss-import -w --no-map`, { cwd: dir } ) cp.on('error', t.end) From d7794767d4e9c85e53f0a9c48f444410ab4c7c7d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 29 Jun 2022 21:39:56 -0400 Subject: [PATCH 201/251] Add tests for ESM config --- test/config.js | 25 +++++++++++++++++++++++++ test/helpers/env.js | 5 ++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/config.js b/test/config.js index a4eb8c6..d75449c 100644 --- a/test/config.js +++ b/test/config.js @@ -28,6 +28,31 @@ test('supports common config', async (t) => { ) }) +test('supports ESM config', async (t) => { + const env = `import postcssImport from 'postcss-import' + export default function () { + return { + plugins: [ + postcssImport() + ] + } + }` + + const dir = await ENV(env, ['a.css'], 'mjs') + + const { error, stderr } = await cli( + ['a.css', '-o', 'output.css', '--no-map'], + dir + ) + + t.falsy(error, stderr) + + t.is( + await read(path.join(dir, 'output.css')), + await read('test/fixtures/a.css') + ) +}) + test("doesn't error on empty config", async (t) => { const env = `module.exports = {}` diff --git a/test/helpers/env.js b/test/helpers/env.js index 7ec542e..dfdba26 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -4,8 +4,7 @@ import { globby } from 'globby' import tmp from './tmp.js' -export default function (config, fixtures) { - fixtures = fixtures || '**/*' +export default function (config, fixtures = '**/*', extension = 'cjs') { const dir = tmp() return Promise.all([ @@ -14,6 +13,6 @@ export default function (config, fixtures) { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) }), - fs.outputFile(path.join(dir, 'postcss.config.cjs'), config), + fs.outputFile(path.join(dir, `postcss.config.${extension}`), config), ]).then(() => dir) } From e5419b5dd587f81a78acbc0f68b33efe150d9ef3 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 29 Jun 2022 21:43:25 -0400 Subject: [PATCH 202/251] 10.0.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d63af2b..f2f8d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 10.0.0 / 2022-06-29 + +- **BREAKING:** Drop Node 12 support ([#438](https://github.com/postcss/postcss-cli/pull/438)) +- Add support for ESM config files ([#437](https://github.com/postcss/postcss-cli/pull/437)) + # 9.1.0 / 2021-12-10 - Don't write to files if they're unchanged ([#320](https://github.com/postcss/postcss-cli/issues/320), [#417](https://github.com/postcss/postcss-cli/pull/417)) diff --git a/package.json b/package.json index 920100e..5874d62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "9.1.0", + "version": "10.0.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 7bf54afe1e3576498de55ca9af94ad1c080891f7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:28:06 -0400 Subject: [PATCH 203/251] Update dependency uuid to v9 (#440) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5874d62..2d31b78 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "postcss-import": "^14.0.0", "prettier": "~2.7.0", "sugarss": "^4.0.0", - "uuid": "^8.0.0" + "uuid": "^9.0.0" }, "peerDependencies": { "postcss": "^8.0.0" From e1b551ef05d050c517b983f6c794fda55110b9fe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:28:34 -0400 Subject: [PATCH 204/251] Update dependency postcss-import to v15 (#439) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d31b78..412137e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint": "^8.2.0", "eslint-config-problems": "6.0.0", "postcss": "^8.0.4", - "postcss-import": "^14.0.0", + "postcss-import": "^15.0.0", "prettier": "~2.7.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" From dcdef56d3603a4fb5b62d266888c0a57719ea99a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:37:05 -0400 Subject: [PATCH 205/251] Update dependency slash to v5 (#442) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 412137e..861fdde 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", - "slash": "^4.0.0", + "slash": "^5.0.0", "yargs": "^17.0.0" }, "devDependencies": { From 9fdc954cfa897b41164f299855250fa3055b061f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 10:56:34 -0400 Subject: [PATCH 206/251] Update dependency eslint-config-problems to v7 (#443) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 861fdde..a753961 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "c8": "^7.9.0", "coveralls": "^3.0.0", "eslint": "^8.2.0", - "eslint-config-problems": "6.0.0", + "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", "prettier": "~2.7.0", From 1cd25c283606be3137b355b944e5dd4b4e2191b0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Nov 2022 11:22:03 -0500 Subject: [PATCH 207/251] Update dependency prettier to ~2.8.0 (#445) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a753961..7bbfc19 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", - "prettier": "~2.7.0", + "prettier": "~2.8.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From e939a68a039b17d49d286c853df908227875d51d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 28 Nov 2022 20:05:13 -0500 Subject: [PATCH 208/251] Update dependency fs-extra to v11 (#447) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7bbfc19..c39207c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "chokidar": "^3.3.0", "dependency-graph": "^0.11.0", - "fs-extra": "^10.0.0", + "fs-extra": "^11.0.0", "get-stdin": "^9.0.0", "globby": "^13.0.0", "picocolors": "^1.0.0", From 83771bda43d200b5229e1db558e936680cbc378d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiago=20Brand=C3=A3o?= <194487+0xradical@users.noreply.github.com> Date: Tue, 29 Nov 2022 17:49:15 -0300 Subject: [PATCH 209/251] Allow non-TTY stdin watch mode (#448) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The presence of stdin doesn't necessarily mean there's an allocated tty. This breaks watch mode in non-TTY stdin contexts (e.g. docker, foreman, etc). A simple process.stdin.isTTY check would theoretically be enough but unfortunately, subprocesses don't have the same API, which are used extensively to test via calls to `spawn`. A simple solution is to inject an env var dependency where we tell the process that it's indeed a TTY-allocated process and so, watch mode with exit handling is good to go. Co-authored-by: Thiago Brandão <194487+thiagobrandam@users.noreply.github.com> --- index.js | 8 +++++++- test/watch.js | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 615638c..da052ce 100755 --- a/index.js +++ b/index.js @@ -61,7 +61,13 @@ let configFile if (argv.env) process.env.NODE_ENV = argv.env if (argv.config) argv.config = path.resolve(argv.config) -if (argv.watch) { +let { isTTY } = process.stdin + +if (process.env.FORCE_IS_TTY === 'true') { + isTTY = true +} + +if (argv.watch && isTTY) { process.stdin.on('end', () => process.exit(0)) process.stdin.resume() } diff --git a/test/watch.js b/test/watch.js index 4cd5391..625df1b 100644 --- a/test/watch.js +++ b/test/watch.js @@ -205,6 +205,10 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { const cp = spawn(`./index.js test/fixtures/a.css -o ${tmp()} -w --no-map`, { shell: true, + env: { + ...process.env, + FORCE_IS_TTY: true, + }, }) cp.on('error', t.end) @@ -212,6 +216,7 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.is(code, 0) t.end() }) + cp.stdin.end() }) From a3574b1f67e4d8c1a78b6b72b501354f545c34d2 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 29 Nov 2022 15:54:57 -0500 Subject: [PATCH 210/251] 10.1.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2f8d32..7c46faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 10.1.0 / 2022-11-29 + +- Allow running `--watch` mode in non-TTY contexts, like Docker ([#448](https://github.com/postcss/postcss-cli/pull/448)) +- Update dependencies + # 10.0.0 / 2022-06-29 - **BREAKING:** Drop Node 12 support ([#438](https://github.com/postcss/postcss-cli/pull/438)) diff --git a/package.json b/package.json index c39207c..1fc3037 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "10.0.0", + "version": "10.1.0", "description": "CLI for PostCSS", "type": "module", "engines": { From fad7e1abb159a1941f3fbd667b45f3eeb8101f82 Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Thu, 4 May 2023 22:07:23 +0900 Subject: [PATCH 211/251] Fix CHANGELOG typos (#450) --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c46faa..47c9bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ # 8.2.0 / 2020-10-29 -- Allow backslashes in paths for better Windows experence ([#355](https://github.com/postcss/postcss-cli/pull/355)) +- Allow backslashes in paths for better Windows experience ([#355](https://github.com/postcss/postcss-cli/pull/355)) # 8.1.0 / 2020-10-08 @@ -76,7 +76,7 @@ # 6.1.3 / 2019-07-08 -- Fix external sorcemap filenames when the directory name contains `.css` ([#283](https://github.com/postcss/postcss-cli/issues/283), [#286](https://github.com/postcss/postcss-cli/pull/286)) +- Fix external sourcemap filenames when the directory name contains `.css` ([#283](https://github.com/postcss/postcss-cli/issues/283), [#286](https://github.com/postcss/postcss-cli/pull/286)) # 6.1.2 / 2019-02-22 @@ -331,4 +331,4 @@ Migration guide: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-t # 0.1.0 / 2015-03-11 -- initial implementaion +- initial implementation From c3f9c3f4baf25f5b76f75bbdc8c765a7af1caf6c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:38:17 -0400 Subject: [PATCH 212/251] Update dependency c8 to v8 (#453) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fc3037..bb7e8d7 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "ava": "^3.1.0", - "c8": "^7.9.0", + "c8": "^8.0.0", "coveralls": "^3.0.0", "eslint": "^8.2.0", "eslint-config-problems": "7.0.1", From d8b2e2af37166e467a29ffd73a81a28954642fa4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Jul 2023 20:53:50 -0400 Subject: [PATCH 213/251] Update dependency prettier to v3 (#454) * Update dependency prettier to v3 * Run prettier --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ryan Zimmerman --- index.js | 24 +++++++++---------- lib/args.js | 10 ++++---- package.json | 2 +- test/base.js | 4 ++-- test/config.js | 16 ++++++------- test/error.js | 10 ++++---- test/glob.js | 6 ++--- test/helpers/cli.js | 2 +- test/helpers/read.js | 2 +- test/misc.js | 2 +- test/stdin.js | 2 +- test/stdout.js | 4 ++-- test/watch.js | 56 ++++++++++++++++++++++---------------------- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/index.js b/index.js index da052ce..f77bf04 100755 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ async function buildCliConfig() { if (e.name && e.name !== 'Error') prefix += `: ${e.name}` return error(`Plugin Error${prefix}: ${msg}'`) } - }) + }), ) : [], } @@ -88,13 +88,13 @@ buildCliConfig() if (input && input.length) { return globby( input.map((i) => slash(String(i))), - { dot: argv.includeDotfiles } + { dot: argv.includeDotfiles }, ) } if (argv.replace || argv.dir) { error( - 'Input Error: Cannot use --dir or --replace when reading from stdin' + 'Input Error: Cannot use --dir or --replace when reading from stdin', ) } @@ -111,7 +111,7 @@ buildCliConfig() if (i.length > 1 && !argv.dir && !argv.replace) { error( - 'Input Error: Must use --dir or --replace with multiple input files' + 'Input Error: Must use --dir or --replace with multiple input files', ) } @@ -146,7 +146,7 @@ buildCliConfig() .concat(getAncestorDirs(file).flatMap(depGraph.dependantsOf)) recompile = recompile.concat( - dependants.filter((file) => input.includes(file)) + dependants.filter((file) => input.includes(file)), ) if (!recompile.length) recompile = input @@ -171,7 +171,7 @@ function rc(ctx, path) { .then((rc) => { if (rc.options.from || rc.options.to) { error( - 'Config Error: Can not set from or to options in config file, use CLI arguments instead' + 'Config Error: Can not set from or to options in config file, use CLI arguments instead', ) } configFile = rc.file @@ -195,7 +195,7 @@ function files(files) { } return read(file).then((content) => css(content, file)) - }) + }), ) } @@ -246,7 +246,7 @@ function css(css, file) { if (!options.to && config.options.map && !config.options.map.inline) { error( - 'Output Error: Cannot output external sourcemaps when writing to STDOUT' + 'Output Error: Cannot output external sourcemaps when writing to STDOUT', ) } @@ -268,8 +268,8 @@ function css(css, file) { const prettyTime = prettyHrtime(process.hrtime(time)) printVerbose( pc.green( - `Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}` - ) + `Finished ${pc.bold(relativePath)} in ${pc.bold(prettyTime)}`, + ), ) const messages = result.warnings() @@ -303,7 +303,7 @@ function dependencies(results) { result.messages .filter((msg) => - msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '' + msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '', ) .map(depGraph.add) .forEach((dependency) => { @@ -311,7 +311,7 @@ function dependencies(results) { messages.push( dependency.glob ? path.join(dependency.dir, dependency.glob) - : dependency.dir + : dependency.dir, ) } else { messages.push(dependency.file) diff --git a/lib/args.js b/lib/args.js index 35f0e83..12d14fa 100644 --- a/lib/args.js +++ b/lib/args.js @@ -7,11 +7,11 @@ const { argv } = yargs(process.argv.slice(2)) $0 ... [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] $0 [OPTIONS] --dir [--watch|-w] - $0 ... [OPTIONS] --replace` + $0 ... [OPTIONS] --replace`, ) .group( ['o', 'd', 'r', 'map', 'no-map', 'watch', 'verbose', 'env'], - 'Basic options:' + 'Basic options:', ) .option('o', { alias: 'output', @@ -50,7 +50,7 @@ const { argv } = yargs(process.argv.slice(2)) }) .group( ['u', 'parser', 'stringifier', 'syntax'], - 'Options for use without a config file:' + 'Options for use without a config file:', ) .option('u', { alias: 'use', @@ -98,7 +98,7 @@ const { argv } = yargs(process.argv.slice(2)) .example('$0 src/**/*.css --base src --dir build', 'Glob Pattern & output') .example( 'cat input.css | $0 -u autoprefixer > output.css', - 'Piping input & output' + 'Piping input & output', ) .epilog( `If no input files are passed, it reads from stdin. If neither -o, --dir, or --replace is passed, it writes to stdout. @@ -107,7 +107,7 @@ If there are multiple input files, the --dir or --replace option must be passed. Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern. -For more details, please see https://github.com/postcss/postcss-cli` +For more details, please see https://github.com/postcss/postcss-cli`, ) if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}` diff --git a/package.json b/package.json index bb7e8d7..190bf99 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", - "prettier": "~2.8.0", + "prettier": "~3.0.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, diff --git a/test/base.js b/test/base.js index 496ca14..a0f965c 100644 --- a/test/base.js +++ b/test/base.js @@ -21,11 +21,11 @@ test('--base --dir works', async (t) => { t.is( await read(path.join(dir, 'level-1/level-2/a.css')), - await read('test/fixtures/base/level-1/level-2/a.css') + await read('test/fixtures/base/level-1/level-2/a.css'), ) t.is( await read(path.join(dir, 'level-1/b.css')), - await read('test/fixtures/base/level-1/b.css') + await read('test/fixtures/base/level-1/b.css'), ) }) diff --git a/test/config.js b/test/config.js index d75449c..b1d7c2c 100644 --- a/test/config.js +++ b/test/config.js @@ -17,14 +17,14 @@ test('supports common config', async (t) => { const { error, stderr } = await cli( ['a.css', '-o', 'output.css', '--no-map'], - dir + dir, ) t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), - await read('test/fixtures/a.css') + await read('test/fixtures/a.css'), ) }) @@ -42,14 +42,14 @@ test('supports ESM config', async (t) => { const { error, stderr } = await cli( ['a.css', '-o', 'output.css', '--no-map'], - dir + dir, ) t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), - await read('test/fixtures/a.css') + await read('test/fixtures/a.css'), ) }) @@ -60,14 +60,14 @@ test("doesn't error on empty config", async (t) => { const { error, stderr } = await cli( ['a.css', '-o', 'output.css', '--no-map'], - dir + dir, ) t.falsy(error, stderr) t.is( await read(path.join(dir, 'output.css')), - await read('test/fixtures/a.css') + await read('test/fixtures/a.css'), ) }) @@ -82,7 +82,7 @@ test('errors if `to` is set', async (t) => { t.regex( stderr, - /Config Error: Can not set from or to options in config file, use CLI arguments instead/ + /Config Error: Can not set from or to options in config file, use CLI arguments instead/, ) }) @@ -97,6 +97,6 @@ test('errors if `from` is set', async (t) => { t.regex( stderr, - /Config Error: Can not set from or to options in config file, use CLI arguments instead/ + /Config Error: Can not set from or to options in config file, use CLI arguments instead/, ) }) diff --git a/test/error.js b/test/error.js index 9901f47..5ff67ef 100644 --- a/test/error.js +++ b/test/error.js @@ -22,7 +22,7 @@ test('--map && writing to stdout', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /Output Error: Cannot output external sourcemaps when writing to STDOUT/ + /Output Error: Cannot output external sourcemaps when writing to STDOUT/, ) }) }) @@ -33,9 +33,9 @@ test('plugin not found', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /Plugin Error: Cannot find package 'postcss-plugin'/ + /Plugin Error: Cannot find package 'postcss-plugin'/, ) - } + }, ) }) @@ -58,8 +58,8 @@ test('CssSyntaxError', (t) => { t.is(code, 1, 'expected non-zero error code') t.regex( error.toString(), - /CssSyntaxError: .*a.css:1:4: Unnecessary curly bracket/ + /CssSyntaxError: .*a.css:1:4: Unnecessary curly bracket/, ) - } + }, ) }) diff --git a/test/glob.js b/test/glob.js index 33917ad..863fc39 100644 --- a/test/glob.js +++ b/test/glob.js @@ -19,14 +19,14 @@ test('works with glob patterns', async (t) => { t.is( await read(path.join(output, 'a.css')), - await read('test/fixtures/glob/a.css') + await read('test/fixtures/glob/a.css'), ) t.is( await read(path.join(output, 'b.css')), - await read('test/fixtures/glob/b.css') + await read('test/fixtures/glob/b.css'), ) t.is( await read(path.join(output, 's.css')), - await read('test/fixtures/glob/s.css') + await read('test/fixtures/glob/s.css'), ) }) diff --git a/test/helpers/cli.js b/test/helpers/cli.js index 565d3ff..838d5a6 100644 --- a/test/helpers/cli.js +++ b/test/helpers/cli.js @@ -13,7 +13,7 @@ export default function (args, cwd) { stdout, stderr, }) - } + }, ) }) } diff --git a/test/helpers/read.js b/test/helpers/read.js index 1dbe451..e9939aa 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -2,6 +2,6 @@ import fs from 'fs-extra' export default function (path) { return fs.readFile(path, 'utf8').then( - (content) => content.replace(/\r\n/g, '\n') // normalize line endings on Windows + (content) => content.replace(/\r\n/g, '\n'), // normalize line endings on Windows ) } diff --git a/test/misc.js b/test/misc.js index 812b6d0..09bde3f 100644 --- a/test/misc.js +++ b/test/misc.js @@ -17,6 +17,6 @@ test('--version', async (t) => { t.truthy( version.stdout.length > 5, - 'expected --version to output version info' + 'expected --version to output version info', ) }) diff --git a/test/stdin.js b/test/stdin.js index 9fb0679..a682436 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -21,7 +21,7 @@ test.cb('reads from stdin', (t) => { t.end() }) .catch(t.end) - } + }, ) fs.createReadStream('test/fixtures/a.css').pipe(cp.stdin) diff --git a/test/stdout.js b/test/stdout.js index 68b6b4b..260180f 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -9,7 +9,7 @@ import read from './helpers/read.js' test.cb('writes to stdout', (t) => { const cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} --parser sugarss -u postcss-import --no-map`, (error, stdout, stderr) => { if (error) t.end(error, stderr) @@ -20,7 +20,7 @@ test.cb('writes to stdout', (t) => { t.end() }) .catch(t.end) - } + }, ) fs.createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) diff --git a/test/watch.js b/test/watch.js index 625df1b..357174a 100644 --- a/test/watch.js +++ b/test/watch.js @@ -52,7 +52,7 @@ testCb('--watch works', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve('index.js')} "*.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -63,7 +63,7 @@ testCb('--watch works', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -116,9 +116,9 @@ testCb('--watch dependencies', (t) => { watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} import.css -o output.css -u postcss-import -w --no-map`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) @@ -130,7 +130,7 @@ testCb('--watch dependencies', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -168,9 +168,9 @@ testCb('--watch dependencies', (t) => { let killed = false const cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} a.css -o output.css -u postcss-import -w --no-map`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.stderr.on('data', (chunk) => { @@ -197,7 +197,7 @@ testCb('--watch dependencies', (t) => { } }) .catch(t.end) - } + }, ) testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { @@ -246,7 +246,7 @@ testCb('--watch watches dependencies', (t) => { } ] } - ` + `, ) .then(() => { // Init watcher: @@ -281,9 +281,9 @@ testCb('--watch watches dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} "s.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -294,7 +294,7 @@ testCb('--watch watches dependencies', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -333,13 +333,13 @@ testCb('--watch watches directory dependencies', (t) => { root.nodes = [] root.append(fs.readFileSync('${path.resolve( dir, - 'base/level-1/level-2/a.css' + 'base/level-1/level-2/a.css', )}', 'utf8')) return root } ] } - ` + `, ) .then(() => { // Init watcher: @@ -358,8 +358,8 @@ testCb('--watch watches directory dependencies', (t) => { .then((css) => fs.writeFile( path.join(dir, 'base/level-1/level-2/a.css'), - css - ) + css, + ), ) .catch(done) } @@ -379,9 +379,9 @@ testCb('--watch watches directory dependencies', (t) => { // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} "s.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -392,7 +392,7 @@ testCb('--watch watches directory dependencies', (t) => { // Helper functions: function isEqual(p, expected) { return Promise.all([read(path.join(dir, p)), read(expected)]).then( - ([a, e]) => t.is(a, e) + ([a, e]) => t.is(a, e), ) } @@ -405,7 +405,7 @@ testCb('--watch watches directory dependencies', (t) => { } }) .catch(t.end) - } + }, ) }) @@ -440,13 +440,13 @@ testCb( root.nodes = [] root.append(fs.readFileSync('${path.resolve( dir, - 'base/level-1/level-2/a.css' + 'base/level-1/level-2/a.css', )}', 'utf8')) return root } ] } - ` + `, ) .then(() => { // Init watcher: @@ -471,7 +471,7 @@ testCb( t.is( modifying, 'a.css', - `Unexpected change to ${p} after modifying ${modifying}` + `Unexpected change to ${p} after modifying ${modifying}`, ) done() } else if (p === 'base/level-1/level-2/unrelated.md') { @@ -484,9 +484,9 @@ testCb( watcher.on('ready', () => { cp = exec( `node ${path.resolve( - 'index.js' + 'index.js', )} "s.css" -o output.css --no-map -w`, - { cwd: dir } + { cwd: dir }, ) cp.on('error', t.end) cp.on('exit', (code) => { @@ -498,7 +498,7 @@ testCb( modifying = 'unrelated.md' fs.writeFile( path.join(dir, 'base/level-1/level-2/unrelated.md'), - 'Some modification' + 'Some modification', ).catch(done) } @@ -506,7 +506,7 @@ testCb( modifying = 'a.css' fs.writeFile( path.join(dir, 'base/level-1/level-2/a.css'), - 'a { color: hotpink }' + 'a { color: hotpink }', ).catch(done) } @@ -520,5 +520,5 @@ testCb( }) .catch(t.end) }) - } + }, ) From c41052a7c0dbeff2947a52b3e80305a4b2405d42 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:13:39 -0400 Subject: [PATCH 214/251] Update actions/checkout action to v4 (#456) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45349ef..f6e2bcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v3 with: From 922c022856a839e286a3f9851e2c0b32621acb81 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:54:06 -0400 Subject: [PATCH 215/251] Update actions/setup-node action to v4 (#458) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6e2bcf..580b5f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - run: git config --global core.autocrlf input - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: npm install From 3b47a48a509ad65c5a3f6000acf0d407dfa6886b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:00:36 -0500 Subject: [PATCH 216/251] Update dependency prettier to ~3.1.0 (#460) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 190bf99..e98404e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "7.0.1", "postcss": "^8.0.4", "postcss-import": "^15.0.0", - "prettier": "~3.0.0", + "prettier": "~3.1.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From 5f728e5882c51d23ea16466991e75791826d31b9 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 5 Dec 2023 15:52:14 -0500 Subject: [PATCH 217/251] BREAKING: Require Node.js v18+ (#464) --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 580b5f0..a7a22ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [14, 16, 18] + node: [18, 20] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/package.json b/package.json index e98404e..c40d153 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CLI for PostCSS", "type": "module", "engines": { - "node": ">=14" + "node": ">=18" }, "bin": { "postcss": "./index.js" From ba1866d9496281c570e6972ea64559edd396671c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:57:23 -0500 Subject: [PATCH 218/251] Update dependency eslint-config-problems to v8 (#451) * Update dependency eslint-config-problems to v8 * Bump eslint peerDependency --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ryan Zimmerman --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c40d153..8aa6302 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ "ava": "^3.1.0", "c8": "^8.0.0", "coveralls": "^3.0.0", - "eslint": "^8.2.0", - "eslint-config-problems": "7.0.1", + "eslint": "^8.55.0", + "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^15.0.0", "prettier": "~3.1.0", From 91ad9e430e7719368e145701042d870c5065c408 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:57:37 -0500 Subject: [PATCH 219/251] Update dependency globby to v14 (#459) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8aa6302..9f05759 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependency-graph": "^0.11.0", "fs-extra": "^11.0.0", "get-stdin": "^9.0.0", - "globby": "^13.0.0", + "globby": "^14.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^4.0.0", "postcss-reporter": "^7.0.0", From e235bfdc49867d5f3b7895e3ea01344efbe7d653 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:57:51 -0500 Subject: [PATCH 220/251] Update dependency postcss-load-config to v5 (#462) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f05759..424b2ba 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "get-stdin": "^9.0.0", "globby": "^14.0.0", "picocolors": "^1.0.0", - "postcss-load-config": "^4.0.0", + "postcss-load-config": "^5.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", From ac801f1f91e22fc36a25af5fc2c36266d3f0c75d Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 5 Dec 2023 16:03:23 -0500 Subject: [PATCH 221/251] 11.0.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c9bf6..1b1e31c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 11.0.0 / 2023-12-05 + +- **BREAKING:** Require Node.js v18+ ([#464](https://github.com/postcss/postcss-cli/pull/464)) +- Upgrade to [`postcss-load-config@5`](https://github.com/postcss/postcss-load-config/blob/main/CHANGELOG.md#50-2023-11-20) for improved ESM & TS config support ([#461](https://github.com/postcss/postcss-cli/issues/461), [#462](https://github.com/postcss/postcss-cli/pull/462)) + # 10.1.0 / 2022-11-29 - Allow running `--watch` mode in non-TTY contexts, like Docker ([#448](https://github.com/postcss/postcss-cli/pull/448)) diff --git a/package.json b/package.json index 424b2ba..7ae796a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "10.1.0", + "version": "11.0.0", "description": "CLI for PostCSS", "type": "module", "engines": { From 278377fa4bda8b2c76c4ee893988eb6f748dda1e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:16:10 -0500 Subject: [PATCH 222/251] Update dependency dependency-graph to v1 (#465) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ae796a..5b90766 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "chokidar": "^3.3.0", - "dependency-graph": "^0.11.0", + "dependency-graph": "^1.0.0", "fs-extra": "^11.0.0", "get-stdin": "^9.0.0", "globby": "^14.0.0", From 9854cead1bae73cd3b29ca342a77882c61775e35 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:13:03 -0500 Subject: [PATCH 223/251] Update dependency postcss-import to v16 (#468) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b90766..242bb24 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint": "^8.55.0", "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", - "postcss-import": "^15.0.0", + "postcss-import": "^16.0.0", "prettier": "~3.1.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" From ea71afd7d44a1cc2f1a0e31cb2e5aba3db23d1c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:13:20 -0500 Subject: [PATCH 224/251] Update dependency c8 to v9 (#469) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 242bb24..82473b4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "ava": "^3.1.0", - "c8": "^8.0.0", + "c8": "^9.0.0", "coveralls": "^3.0.0", "eslint": "^8.55.0", "eslint-config-problems": "8.0.0", From 4c5a69c6a725d8b6a2d9c1fd35474e8d8273f9b9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:33:18 -0500 Subject: [PATCH 225/251] Update dependency prettier to ~3.2.0 (#470) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82473b4..d7db6f6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.1.0", + "prettier": "~3.2.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From 528af4c30beffcce0653eb7046a6f331a0fd5ffd Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 29 Jan 2024 20:49:02 +0100 Subject: [PATCH 226/251] Adding link to PostCSS (#472) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9dc9a2d..a390e3e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@

PostCSS CLI

+PostCSS CLI is a command line interface for [PostCSS](https://postcss.org/) +

Install

```bash From 0f52be713e121c7e4476b380ce7bab9529890b7c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:49:29 -0400 Subject: [PATCH 227/251] Update dependency prettier to ~3.3.0 (#477) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d7db6f6..0664ed3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.2.0", + "prettier": "~3.3.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From 5f9f92af5f070313fc710a62db0c58705fb891eb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:33:45 -0500 Subject: [PATCH 228/251] Update dependency prettier to ~3.4.0 (#484) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0664ed3..41599f6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.3.0", + "prettier": "~3.4.0", "sugarss": "^4.0.0", "uuid": "^9.0.0" }, From b5d8f0ed6e25e7e0f0662e9aed3bfd7def9e6573 Mon Sep 17 00:00:00 2001 From: v1rtl Date: Wed, 12 Mar 2025 19:09:20 +0200 Subject: [PATCH 229/251] feat: replace globby with tinyglobby and remove get-stdin in favor of builtin stream.consumers.text (#489) --- index.js | 8 ++++---- package.json | 3 +-- test/helpers/env.js | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index f77bf04..266c912 100755 --- a/index.js +++ b/index.js @@ -4,10 +4,10 @@ import fs from 'fs-extra' import path from 'path' import prettyHrtime from 'pretty-hrtime' -import stdin from 'get-stdin' +import { text } from 'stream/consumers' import read from 'read-cache' import pc from 'picocolors' -import { globby } from 'globby' +import { glob } from 'tinyglobby' import slash from 'slash' import chokidar from 'chokidar' @@ -86,7 +86,7 @@ buildCliConfig() } if (input && input.length) { - return globby( + return glob( input.map((i) => slash(String(i))), { dot: argv.includeDotfiles }, ) @@ -188,7 +188,7 @@ function files(files) { return Promise.all( files.map((file) => { if (file === 'stdin') { - return stdin().then((content) => { + return text(process.stdin).then((content) => { if (!content) return error('Input Error: Did not receive any STDIN') return css(content, 'stdin') }) diff --git a/package.json b/package.json index 41599f6..92d07ea 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,13 @@ "chokidar": "^3.3.0", "dependency-graph": "^1.0.0", "fs-extra": "^11.0.0", - "get-stdin": "^9.0.0", - "globby": "^14.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^5.0.0", "postcss-reporter": "^7.0.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "slash": "^5.0.0", + "tinyglobby": "^0.2.12", "yargs": "^17.0.0" }, "devDependencies": { diff --git a/test/helpers/env.js b/test/helpers/env.js index dfdba26..017df87 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,6 +1,6 @@ import fs from 'fs-extra' import path from 'path' -import { globby } from 'globby' +import { glob } from 'tinyglobby' import tmp from './tmp.js' @@ -8,7 +8,7 @@ export default function (config, fixtures = '**/*', extension = 'cjs') { const dir = tmp() return Promise.all([ - globby(fixtures, { cwd: 'test/fixtures' }).then((list) => { + glob(fixtures, { cwd: 'test/fixtures' }).then((list) => { return list.map((item) => { return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) }) From bfad16da0dad084a0961efb1cf44b626fac3a2e0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:10:53 -0400 Subject: [PATCH 230/251] Update dependency c8 to v10 (#480) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92d07ea..d95f104 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "ava": "^3.1.0", - "c8": "^9.0.0", + "c8": "^10.0.0", "coveralls": "^3.0.0", "eslint": "^8.55.0", "eslint-config-problems": "8.0.0", From bd416f5b326562a228202b1b6b23495ffcffa8ee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:13:11 -0400 Subject: [PATCH 231/251] Update dependency uuid to v11 (#482) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d95f104..d3c71e8 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "postcss-import": "^16.0.0", "prettier": "~3.4.0", "sugarss": "^4.0.0", - "uuid": "^9.0.0" + "uuid": "^11.0.0" }, "peerDependencies": { "postcss": "^8.0.0" From 1363a6549a622a27b4a5d8e55c65d406aae94cbd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:14:38 -0400 Subject: [PATCH 232/251] Update dependency prettier to ~3.5.0 (#488) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3c71e8..d62916a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "eslint-config-problems": "8.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.4.0", + "prettier": "~3.5.0", "sugarss": "^4.0.0", "uuid": "^11.0.0" }, From 733ef42fa6b596139787c721ecfbc2b50d915fae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:17:04 -0400 Subject: [PATCH 233/251] chore(deps): update dependency sugarss to v5 (#483) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d62916a..86f0ecf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "postcss": "^8.0.4", "postcss-import": "^16.0.0", "prettier": "~3.5.0", - "sugarss": "^4.0.0", + "sugarss": "^5.0.0", "uuid": "^11.0.0" }, "peerDependencies": { From 0dc4eba537acf36af7747753027c99d768644820 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 12 Mar 2025 13:28:07 -0400 Subject: [PATCH 234/251] Use eslint v9 + flat config (#490) --- .eslintrc.yaml | 7 ------- eslint.config.js | 16 ++++++++++++++++ package.json | 5 +++-- 3 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 .eslintrc.yaml create mode 100644 eslint.config.js diff --git a/.eslintrc.yaml b/.eslintrc.yaml deleted file mode 100644 index d838ba7..0000000 --- a/.eslintrc.yaml +++ /dev/null @@ -1,7 +0,0 @@ -env: - node: true -parserOptions: - sourceType: module -extends: problems -rules: - no-console: off diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..26e500f --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,16 @@ +import problems from 'eslint-config-problems' +import globals from 'globals' + +export default [ + problems, + { + languageOptions: { + globals: { + ...globals.node, + }, + }, + rules: { + 'no-console': 'off', + }, + }, +] diff --git a/package.json b/package.json index 86f0ecf..ff99339 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,9 @@ "ava": "^3.1.0", "c8": "^10.0.0", "coveralls": "^3.0.0", - "eslint": "^8.55.0", - "eslint-config-problems": "8.0.0", + "eslint": "^9.22.0", + "eslint-config-problems": "9.0.0", + "globals": "^16.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", "prettier": "~3.5.0", From 7bea18069b334b0d537d5c772ce20b1637c7e5d6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 12 Mar 2025 13:38:50 -0400 Subject: [PATCH 235/251] 11.0.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b1e31c..4fed6ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 11.0.1 / 2025-03-12 + +- Update and minimize dependencies + # 11.0.0 / 2023-12-05 - **BREAKING:** Require Node.js v18+ ([#464](https://github.com/postcss/postcss-cli/pull/464)) diff --git a/package.json b/package.json index ff99339..dcb8866 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-cli", - "version": "11.0.0", + "version": "11.0.1", "description": "CLI for PostCSS", "type": "module", "engines": { From e285fb8e36c10e1eecbb1e669a39386cedbfc7e6 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 12 Mar 2025 13:42:32 -0400 Subject: [PATCH 236/251] Add Node 22 to CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7a22ea..8c5a03f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [18, 20] + node: [18, 20, 22] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: From 0ca707ca969b5075aebc45d0013238da652ac973 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:28:48 -0400 Subject: [PATCH 237/251] chore(deps): update dependency prettier to ~3.6.0 (#494) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dcb8866..6e1f94e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "globals": "^16.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.5.0", + "prettier": "~3.6.0", "sugarss": "^5.0.0", "uuid": "^11.0.0" }, From 0e9aa4613ecb5ed38e22c77e774b08353eb93e23 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:43:14 -0500 Subject: [PATCH 238/251] chore(deps): update dependency globals to v17 (#506) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e1f94e..a97d64e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "coveralls": "^3.0.0", "eslint": "^9.22.0", "eslint-config-problems": "9.0.0", - "globals": "^16.0.0", + "globals": "^17.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", "prettier": "~3.6.0", From c0f08222cff38fa200bf8f51001c9e6e2bbbc966 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:43:56 -0500 Subject: [PATCH 239/251] chore(deps): update dependency prettier to ~3.7.0 (#502) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a97d64e..3618369 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "globals": "^17.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.6.0", + "prettier": "~3.7.0", "sugarss": "^5.0.0", "uuid": "^11.0.0" }, From 6612d642f09fb0a3451ad32393fd49f63ca3f577 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:44:57 -0500 Subject: [PATCH 240/251] chore(deps): update actions/checkout action to v6 (#500) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c5a03f..2d6f6d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v4 with: From 4e844293f140df18046103aaeed7bad5ad33f24a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:46:11 -0500 Subject: [PATCH 241/251] chore(deps): update actions/setup-node action to v6 (#499) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d6f6d4..82ebade 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - run: git config --global core.autocrlf input - uses: actions/checkout@v6 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} - run: npm install From 032efde0f7c342e08ab00559b3b1486493a78f22 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 11:48:15 -0500 Subject: [PATCH 242/251] chore(deps): update dependency uuid to v13 (#498) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3618369..9556624 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "postcss-import": "^16.0.0", "prettier": "~3.7.0", "sugarss": "^5.0.0", - "uuid": "^11.0.0" + "uuid": "^13.0.0" }, "peerDependencies": { "postcss": "^8.0.0" From e600465736b904ebd8b650d54e7b71652b17d2ac Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 6 Jan 2026 11:50:31 -0500 Subject: [PATCH 243/251] Add Node v24 to CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82ebade..b31ce99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: strategy: matrix: - node: [18, 20, 22] + node: [18, 20, 22, 24] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: From f2c2e8a119c03049be4ce7c92ab83f535a360a2c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 11:20:37 -0500 Subject: [PATCH 244/251] chore(deps): update dependency prettier to ~3.8.0 (#507) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9556624..6e5981a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "globals": "^17.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.7.0", + "prettier": "~3.8.0", "sugarss": "^5.0.0", "uuid": "^13.0.0" }, From 27e9fdd6b20115d0dc7044939a97c1dc4365c886 Mon Sep 17 00:00:00 2001 From: Roli Bosch Date: Fri, 6 Mar 2026 10:04:40 -0800 Subject: [PATCH 245/251] chore: replace fs-extra with native Node.js fs (#510) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: replace fs-extra with native Node.js fs Replace fs-extra with native Node.js fs APIs (node:fs/promises, node:fs). All replacements are available on the supported Node >= 18: - fs.pathExists() → fs.access() with boolean resolution - fs.outputFile() → fs.mkdir({ recursive: true }) + fs.writeFile() - fs.copy() → fs.copyFile() (glob ensures file-only results) - fs.emptyDir() → fs.rm({ recursive, force }) + fs.mkdir({ recursive }) - fs.remove() → fs.rm({ recursive, force }) - fs.createReadStream() → named import from node:fs This removes 1 runtime dependency (fs-extra + 3 transitive deps). Co-Authored-By: Claude Opus 4.6 * refactor: convert env helper to async/await per review feedback --------- Co-authored-by: Claude Opus 4.6 --- index.js | 10 +++++++--- package.json | 1 - test/ext.js | 16 +++++++++++++--- test/helpers/clean.js | 8 +++++--- test/helpers/env.js | 24 +++++++++++++++--------- test/helpers/read.js | 2 +- test/map.js | 9 +++++++-- test/replace.js | 7 ++++--- test/stdin.js | 4 ++-- test/stdout.js | 4 ++-- test/unchanged.js | 2 +- test/watch.js | 2 +- 12 files changed, 58 insertions(+), 31 deletions(-) diff --git a/index.js b/index.js index 266c912..c7a0cd8 100755 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -import fs from 'fs-extra' +import fs from 'node:fs/promises' import path from 'path' import prettyHrtime from 'pretty-hrtime' @@ -286,10 +286,14 @@ function css(css, file) { }) async function outputFile(file, string) { - const fileExists = await fs.pathExists(file) + const fileExists = await fs.access(file).then( + () => true, + () => false, + ) const currentValue = fileExists ? await fs.readFile(file, 'utf8') : null if (currentValue === string) return - return fs.outputFile(file, string) + await fs.mkdir(path.dirname(file), { recursive: true }) + return fs.writeFile(file, string) } } diff --git a/package.json b/package.json index 6e5981a..ccde399 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "dependencies": { "chokidar": "^3.3.0", "dependency-graph": "^1.0.0", - "fs-extra": "^11.0.0", "picocolors": "^1.0.0", "postcss-load-config": "^5.0.0", "postcss-reporter": "^7.0.0", diff --git a/test/ext.js b/test/ext.js index 329f2c4..675939d 100644 --- a/test/ext.js +++ b/test/ext.js @@ -1,6 +1,6 @@ import test from 'ava' -import fs from 'fs-extra' +import fs from 'node:fs/promises' import path from 'path' import cli from './helpers/cli.js' @@ -20,7 +20,12 @@ test('--ext works', async (t) => { ]) t.falsy(error, stderr) - t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) + t.truthy( + await fs.access(path.join(dir, 'a.css')).then( + () => true, + () => false, + ), + ) }) test('--ext works with no leading dot', async (t) => { @@ -37,5 +42,10 @@ test('--ext works with no leading dot', async (t) => { ]) t.falsy(error, stderr) - t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) + t.truthy( + await fs.access(path.join(dir, 'a.css')).then( + () => true, + () => false, + ), + ) }) diff --git a/test/helpers/clean.js b/test/helpers/clean.js index 73bb191..7591d7b 100644 --- a/test/helpers/clean.js +++ b/test/helpers/clean.js @@ -1,8 +1,10 @@ -import fs from 'fs-extra' +import fs from 'node:fs/promises' Promise.all([ - fs.emptyDir('./test/fixtures/.tmp/'), - fs.remove('./coverage'), + fs + .rm('./test/fixtures/.tmp/', { recursive: true, force: true }) + .then(() => fs.mkdir('./test/fixtures/.tmp/', { recursive: true })), + fs.rm('./coverage', { recursive: true, force: true }), ]).catch((err) => { console.error(err) process.exit(1) diff --git a/test/helpers/env.js b/test/helpers/env.js index 017df87..0fd9549 100644 --- a/test/helpers/env.js +++ b/test/helpers/env.js @@ -1,18 +1,24 @@ -import fs from 'fs-extra' +import fs from 'node:fs/promises' import path from 'path' import { glob } from 'tinyglobby' import tmp from './tmp.js' -export default function (config, fixtures = '**/*', extension = 'cjs') { +export default async function (config, fixtures = '**/*', extension = 'cjs') { const dir = tmp() - return Promise.all([ - glob(fixtures, { cwd: 'test/fixtures' }).then((list) => { - return list.map((item) => { - return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) - }) + await fs.mkdir(dir, { recursive: true }) + + const list = await glob(fixtures, { cwd: 'test/fixtures' }) + + await Promise.all([ + ...list.map(async (item) => { + const dest = path.join(dir, item) + await fs.mkdir(path.dirname(dest), { recursive: true }) + await fs.copyFile(path.join('test/fixtures', item), dest) }), - fs.outputFile(path.join(dir, `postcss.config.${extension}`), config), - ]).then(() => dir) + fs.writeFile(path.join(dir, `postcss.config.${extension}`), config), + ]) + + return dir } diff --git a/test/helpers/read.js b/test/helpers/read.js index e9939aa..17d969f 100644 --- a/test/helpers/read.js +++ b/test/helpers/read.js @@ -1,4 +1,4 @@ -import fs from 'fs-extra' +import fs from 'node:fs/promises' export default function (path) { return fs.readFile(path, 'utf8').then( diff --git a/test/map.js b/test/map.js index 4783010..a3febb9 100644 --- a/test/map.js +++ b/test/map.js @@ -1,5 +1,5 @@ import test from 'ava' -import fs from 'fs-extra' +import fs from 'node:fs/promises' import cli from './helpers/cli.js' import tmp from './helpers/tmp.js' @@ -35,7 +35,12 @@ test('--map generates external sourcemaps', async (t) => { t.falsy(error, stderr) - t.truthy(await fs.pathExists(output.replace('.css', '.css.map'))) + t.truthy( + await fs.access(output.replace('.css', '.css.map')).then( + () => true, + () => false, + ), + ) }) test('--no-map disables internal sourcemaps', async (t) => { diff --git a/test/replace.js b/test/replace.js index dd24b98..7032493 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,6 +1,6 @@ import test from 'ava' -import fs from 'fs-extra' +import fs from 'node:fs/promises' import path from 'path' import cli from './helpers/cli.js' @@ -12,9 +12,10 @@ test('--replace works', async (t) => { const output = path.join(dir, 'output.css') + await fs.mkdir(dir, { recursive: true }) await Promise.all([ - fs.copy('test/fixtures/import.css', output), - fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')), + fs.copyFile('test/fixtures/import.css', output), + fs.copyFile('test/fixtures/a.css', path.join(dir, 'a.css')), ]) const { error, stderr } = await cli([ diff --git a/test/stdin.js b/test/stdin.js index a682436..9cdf928 100644 --- a/test/stdin.js +++ b/test/stdin.js @@ -1,6 +1,6 @@ import test from 'ava' -import fs from 'fs-extra' +import { createReadStream } from 'node:fs' import path from 'path' import { exec } from 'child_process' @@ -24,5 +24,5 @@ test.cb('reads from stdin', (t) => { }, ) - fs.createReadStream('test/fixtures/a.css').pipe(cp.stdin) + createReadStream('test/fixtures/a.css').pipe(cp.stdin) }) diff --git a/test/stdout.js b/test/stdout.js index 260180f..b53de43 100644 --- a/test/stdout.js +++ b/test/stdout.js @@ -1,6 +1,6 @@ import test from 'ava' -import fs from 'fs-extra' +import { createReadStream } from 'node:fs' import path from 'path' import { exec } from 'child_process' @@ -23,5 +23,5 @@ test.cb('writes to stdout', (t) => { }, ) - fs.createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) + createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) }) diff --git a/test/unchanged.js b/test/unchanged.js index 4598530..beabdb1 100644 --- a/test/unchanged.js +++ b/test/unchanged.js @@ -1,4 +1,4 @@ -import fs from 'fs-extra' +import fs from 'node:fs/promises' import test from 'ava' import cli from './helpers/cli.js' diff --git a/test/watch.js b/test/watch.js index 357174a..ed0e873 100644 --- a/test/watch.js +++ b/test/watch.js @@ -1,6 +1,6 @@ import test from 'ava' -import fs from 'fs-extra' +import fs from 'node:fs/promises' import path from 'path' import { exec, spawn } from 'child_process' import chokidar from 'chokidar' From b227a930b1cd7f6e1476332273e6888dd54e2ca5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 15:14:50 -0400 Subject: [PATCH 246/251] Update actions/setup-node action to v7 (#518) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b31ce99..2046008 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - run: git config --global core.autocrlf input - uses: actions/checkout@v6 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v6 + uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} - run: npm install From c1ab734450d5090cf2265f51e5569ef9db112c07 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 15:15:23 -0400 Subject: [PATCH 247/251] Update dependency prettier to ~3.9.0 (#517) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ccde399..70194cd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "globals": "^17.0.0", "postcss": "^8.0.4", "postcss-import": "^16.0.0", - "prettier": "~3.8.0", + "prettier": "~3.9.0", "sugarss": "^5.0.0", "uuid": "^13.0.0" }, From 86501b0a24b176efa0d1751f58d2ef43590cdfad Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 15:17:15 -0400 Subject: [PATCH 248/251] Update actions/checkout action to v7 (#516) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2046008..eb92fc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v7 with: From 0c6ddedeff69648f8ba478dbaa5eca25c163228a Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 11 Aug 2026 15:56:09 -0400 Subject: [PATCH 249/251] Simplify dependencies() to use flatMap() (#520) --- index.js | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index c7a0cd8..7cca0e5 100755 --- a/index.js +++ b/index.js @@ -300,30 +300,24 @@ function css(css, file) { function dependencies(results) { if (!Array.isArray(results)) results = [results] - const messages = [] + return results.flatMap((result) => { + if (result.messages.length <= 0) return [] - results.forEach((result) => { - if (result.messages <= 0) return - - result.messages - .filter((msg) => - msg.type === 'dependency' || msg.type === 'dir-dependency' ? msg : '', + return result.messages + .filter( + (msg) => msg.type === 'dependency' || msg.type === 'dir-dependency', ) .map(depGraph.add) - .forEach((dependency) => { + .map((dependency) => { if (dependency.type === 'dir-dependency') { - messages.push( - dependency.glob - ? path.join(dependency.dir, dependency.glob) - : dependency.dir, - ) - } else { - messages.push(dependency.file) + return dependency.glob + ? path.join(dependency.dir, dependency.glob) + : dependency.dir } + + return dependency.file }) }) - - return messages } function printVerbose(message) { From 1489c2f98f812cc6c6cff7bf078b54eab1aee34f Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 11 Aug 2026 16:02:12 -0400 Subject: [PATCH 250/251] Remove incorrect comments --- test/watch.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/watch.js b/test/watch.js index ed0e873..9895a19 100644 --- a/test/watch.js +++ b/test/watch.js @@ -278,7 +278,6 @@ testCb('--watch watches dependencies', (t) => { // Start postcss-cli: watcher.on('ready', () => { - // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( 'index.js', @@ -376,7 +375,6 @@ testCb('--watch watches directory dependencies', (t) => { // Start postcss-cli: watcher.on('ready', () => { - // Using exec() and quoting "*.css" to test watch's glob handling: cp = exec( `node ${path.resolve( 'index.js', From 35ae0858987436644d20bb58a9a67d951615909c Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Tue, 11 Aug 2026 16:03:21 -0400 Subject: [PATCH 251/251] Add test for directory as input (#521) --- test/glob.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/glob.js b/test/glob.js index 863fc39..38743f7 100644 --- a/test/glob.js +++ b/test/glob.js @@ -30,3 +30,29 @@ test('works with glob patterns', async (t) => { await read('test/fixtures/glob/s.css'), ) }) + +test('works with directory input', async (t) => { + const output = tmp() + + const { error, stderr } = await cli([ + 'test/fixtures/glob', + '-d', + output, + '--no-map', + ]) + + t.falsy(error, stderr) + + t.is( + await read(path.join(output, 'a.css')), + await read('test/fixtures/glob/a.css'), + ) + t.is( + await read(path.join(output, 'b.css')), + await read('test/fixtures/glob/b.css'), + ) + t.is( + await read(path.join(output, 's.css')), + await read('test/fixtures/glob/s.css'), + ) +})