Skip to content

Commit

Permalink
Update dependency prettier to v3 (#454)
Browse files Browse the repository at this point in the history
* Update dependency prettier to v3

* Run prettier

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ryan Zimmerman <opensrc@ryanzim.com>
  • Loading branch information
renovate[bot] and RyanZim authored Jul 16, 2023
1 parent c3f9c3f commit d8b2e2a
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 70 deletions.
24 changes: 12 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function buildCliConfig() {
if (e.name && e.name !== 'Error') prefix += `: ${e.name}`
return error(`Plugin Error${prefix}: ${msg}'`)
}
})
}),
)
: [],
}
Expand Down Expand Up @@ -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',
)
}

Expand All @@ -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',
)
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -195,7 +195,7 @@ function files(files) {
}

return read(file).then((content) => css(content, file))
})
}),
)
}

Expand Down Expand Up @@ -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',
)
}

Expand All @@ -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()
Expand Down Expand Up @@ -303,15 +303,15 @@ 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) => {
if (dependency.type === 'dir-dependency') {
messages.push(
dependency.glob
? path.join(dependency.dir, dependency.glob)
: dependency.dir
: dependency.dir,
)
} else {
messages.push(dependency.file)
Expand Down
10 changes: 5 additions & 5 deletions lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const { argv } = yargs(process.argv.slice(2))
$0 <input.css>... [OPTIONS] --dir <output-directory> [--watch|-w]
$0 <input-directory> [OPTIONS] --dir <output-directory> [--watch|-w]
$0 <input-glob-pattern> [OPTIONS] --dir <output-directory> [--watch|-w]
$0 <input.css>... [OPTIONS] --replace`
$0 <input.css>... [OPTIONS] --replace`,
)
.group(
['o', 'd', 'r', 'map', 'no-map', 'watch', 'verbose', 'env'],
'Basic options:'
'Basic options:',
)
.option('o', {
alias: 'output',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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.
Expand All @@ -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}`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions test/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
})
16 changes: 8 additions & 8 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
})

Expand All @@ -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'),
)
})

Expand All @@ -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'),
)
})

Expand All @@ -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/,
)
})

Expand All @@ -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/,
)
})
10 changes: 5 additions & 5 deletions test/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
)
})
})
Expand All @@ -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'/,
)
}
},
)
})

Expand All @@ -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/,
)
}
},
)
})
6 changes: 3 additions & 3 deletions test/glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
})
2 changes: 1 addition & 1 deletion test/helpers/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function (args, cwd) {
stdout,
stderr,
})
}
},
)
})
}
2 changes: 1 addition & 1 deletion test/helpers/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
2 changes: 1 addition & 1 deletion test/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
})
2 changes: 1 addition & 1 deletion test/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.cb('reads from stdin', (t) => {
t.end()
})
.catch(t.end)
}
},
)

fs.createReadStream('test/fixtures/a.css').pipe(cp.stdin)
Expand Down
4 changes: 2 additions & 2 deletions test/stdout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,7 +20,7 @@ test.cb('writes to stdout', (t) => {
t.end()
})
.catch(t.end)
}
},
)

fs.createReadStream('./test/fixtures/a.sss').pipe(cp.stdin)
Expand Down
Loading

0 comments on commit d8b2e2a

Please sign in to comment.