mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: update tooling (#11388)
This commit is contained in:
parent
aeae19192a
commit
52263f7241
@ -15,12 +15,12 @@
|
|||||||
"doctest": "wireit",
|
"doctest": "wireit",
|
||||||
"format": "run-s format:*",
|
"format": "run-s format:*",
|
||||||
"format:eslint": "eslint --ext js --ext ts --fix .",
|
"format:eslint": "eslint --ext js --ext ts --fix .",
|
||||||
"format:expectations": "node tools/sort-test-expectations.js",
|
"format:expectations": "node tools/sort-test-expectations.mjs",
|
||||||
"format:prettier": "prettier --write .",
|
"format:prettier": "prettier --write .",
|
||||||
"lint": "run-s lint:*",
|
"lint": "run-s lint:*",
|
||||||
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet . || eslint --ext js --ext ts .)",
|
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet . || eslint --ext js --ext ts .)",
|
||||||
"lint:prettier": "prettier --check .",
|
"lint:prettier": "prettier --check .",
|
||||||
"lint:expectations": "node tools/sort-test-expectations.js --lint",
|
"lint:expectations": "node tools/sort-test-expectations.mjs --lint",
|
||||||
"postinstall": "npm run postinstall --workspaces --if-present",
|
"postinstall": "npm run postinstall --workspaces --if-present",
|
||||||
"prepare": "npm run prepare --workspaces --if-present",
|
"prepare": "npm run prepare --workspaces --if-present",
|
||||||
"test": "wireit",
|
"test": "wireit",
|
||||||
|
@ -15,17 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: this could be an eslint rule probably.
|
// TODO: this could be an eslint rule probably.
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import url from 'url';
|
||||||
|
|
||||||
const fs = require('fs');
|
import prettier from 'prettier';
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const prettier = require('@prettier/sync');
|
|
||||||
|
|
||||||
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||||
const source = 'test/TestExpectations.json';
|
const source = 'test/TestExpectations.json';
|
||||||
|
|
||||||
const testExpectations = JSON.parse(fs.readFileSync(source, 'utf-8'));
|
const testExpectations = JSON.parse(fs.readFileSync(source, 'utf-8'));
|
||||||
|
const committedExpectations = structuredClone(testExpectations);
|
||||||
|
|
||||||
const commitedExpectations = structuredClone(testExpectations);
|
const prettierConfig = await import(
|
||||||
|
path.join(__dirname, '..', '.prettierrc.cjs')
|
||||||
|
);
|
||||||
|
|
||||||
function getSpecificity(item) {
|
function getSpecificity(item) {
|
||||||
return (
|
return (
|
||||||
@ -54,7 +57,7 @@ testExpectations.forEach(item => {
|
|||||||
|
|
||||||
if (process.argv.includes('--lint')) {
|
if (process.argv.includes('--lint')) {
|
||||||
if (
|
if (
|
||||||
JSON.stringify(commitedExpectations) !== JSON.stringify(testExpectations)
|
JSON.stringify(committedExpectations) !== JSON.stringify(testExpectations)
|
||||||
) {
|
) {
|
||||||
console.error(
|
console.error(
|
||||||
`${source} is not formatted properly. Run 'npm run format:expectations'.`
|
`${source} is not formatted properly. Run 'npm run format:expectations'.`
|
||||||
@ -64,8 +67,8 @@ if (process.argv.includes('--lint')) {
|
|||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
source,
|
source,
|
||||||
prettier.format(JSON.stringify(testExpectations), {
|
await prettier.format(JSON.stringify(testExpectations), {
|
||||||
...require(path.join(__dirname, '..', '.prettierrc.cjs')),
|
...prettierConfig,
|
||||||
parser: 'json',
|
parser: 'json',
|
||||||
})
|
})
|
||||||
);
|
);
|
Loading…
Reference in New Issue
Block a user