Skip to content

Commit ee90e3d

Browse files
committed
update and run prettier
Added prettier option `--arrow-parens avoid` to cause least change
1 parent 5a82e38 commit ee90e3d

5 files changed

+48
-44
lines changed

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@
1313
"patch-package": "./index.js"
1414
},
1515
"config": {
16-
"allsrc": "src{/**,}/*.ts integration-tests{/**,}/*.ts property-based-tests{/**,}/*.ts"
16+
"allsrc": "src{/**,}/*.ts integration-tests{/**,}/*.ts property-based-tests{/**,}/*.ts",
17+
"prettier_options": "--no-semi --trailing-comma=all --arrow-parens avoid"
1718
},
1819
"scripts": {
1920
"precommit": "tsc --noEmit && lint-staged",
2021
"prepublishOnly": "yarn run clean && yarn run build",
2122
"build": "tsc --project tsconfig.build.json",
2223
"new-integration-test": "ts-node integration-tests/newIntegrationTest.ts",
2324
"clean": "rimraf dist patch-package.test*.tgz",
24-
"format": "prettier --no-semi --write --trailing-comma=all $npm_package_config_allsrc",
25+
"format": "prettier $npm_package_config_prettier_options --write $npm_package_config_allsrc",
26+
"format:verify": "prettier $npm_package_config_prettier_options --list-different",
2527
"lint": "eslint $npm_package_config_allsrc",
2628
"prepack": "rimraf dist/**/*.test.js",
2729
"test": "./run-tests.sh --runInBand"
2830
},
2931
"lint-staged": {
3032
"*.ts": [
3133
"eslint",
32-
"prettier --no-semi --trailing-comma=all --list-different"
34+
"yarn format:verify"
3335
]
3436
},
3537
"jest": {
@@ -70,7 +72,7 @@
7072
"jest": "^24.5.0",
7173
"lint-staged": "^8.1.5",
7274
"np": "^6.2.0",
73-
"prettier": "^1.18.2",
75+
"prettier": "^2.1.1",
7476
"randomstring": "^1.1.5",
7577
"ts-jest": "^24.0.0",
7678
"ts-node": "8.0.3",

src/makePatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function makePatch({
103103
)).version as string
104104

105105
// copy .npmrc/.yarnrc in case packages are hosted in private registry
106-
[".npmrc", ".yarnrc"].forEach(rcFile => {
106+
;[".npmrc", ".yarnrc"].forEach(rcFile => {
107107
const rcPath = join(appPath, rcFile)
108108
if (existsSync(rcPath)) {
109109
copySync(rcPath, join(tmpRepo.name, rcFile))

src/packageIsDevDependency.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ export function packageIsDevDependency({
1414
return false
1515
}
1616
const { devDependencies } = require(packageJsonPath)
17-
return Boolean(devDependencies && devDependencies[packageDetails.packageNames[0]])
17+
return Boolean(
18+
devDependencies && devDependencies[packageDetails.packageNames[0]],
19+
)
1820
}

src/spawnSafe.ts

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
import { sync as spawnSync } from "cross-spawn"
2-
import { SpawnOptions } from "child_process"
3-
4-
export interface SpawnSafeOptions extends SpawnOptions {
5-
throwOnError?: boolean
6-
logStdErrOnError?: boolean
7-
}
8-
9-
const defaultOptions: SpawnSafeOptions = {
10-
logStdErrOnError: true,
11-
throwOnError: true,
12-
}
13-
14-
export const spawnSafeSync = (
15-
command: string,
16-
args?: string[],
17-
options?: SpawnSafeOptions,
18-
) => {
19-
const mergedOptions = Object.assign({}, defaultOptions, options)
20-
const result = spawnSync(command, args, options)
21-
if (result.error || result.status !== 0) {
22-
if (mergedOptions.logStdErrOnError) {
23-
if (result.stderr) {
24-
console.error(result.stderr.toString())
25-
} else if (result.error) {
26-
console.error(result.error)
27-
}
28-
}
29-
if (mergedOptions.throwOnError) {
30-
throw result
31-
}
32-
}
33-
return result
34-
}
1+
import { sync as spawnSync } from "cross-spawn"
2+
import { SpawnOptions } from "child_process"
3+
4+
export interface SpawnSafeOptions extends SpawnOptions {
5+
throwOnError?: boolean
6+
logStdErrOnError?: boolean
7+
}
8+
9+
const defaultOptions: SpawnSafeOptions = {
10+
logStdErrOnError: true,
11+
throwOnError: true,
12+
}
13+
14+
export const spawnSafeSync = (
15+
command: string,
16+
args?: string[],
17+
options?: SpawnSafeOptions,
18+
) => {
19+
const mergedOptions = Object.assign({}, defaultOptions, options)
20+
const result = spawnSync(command, args, options)
21+
if (result.error || result.status !== 0) {
22+
if (mergedOptions.logStdErrOnError) {
23+
if (result.stderr) {
24+
console.error(result.stderr.toString())
25+
} else if (result.error) {
26+
console.error(result.error)
27+
}
28+
}
29+
if (mergedOptions.throwOnError) {
30+
throw result
31+
}
32+
}
33+
return result
34+
}

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -4754,10 +4754,10 @@ prepend-http@^2.0.0:
47544754
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
47554755
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
47564756

4757-
prettier@^1.18.2:
4758-
version "1.18.2"
4759-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
4760-
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==
4757+
prettier@^2.1.1:
4758+
version "2.1.1"
4759+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.1.tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6"
4760+
integrity sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==
47614761

47624762
pretty-format@^24.5.0:
47634763
version "24.5.0"

0 commit comments

Comments
 (0)