Skip to content

Commit 61ef434

Browse files
committed
update and run prettier
1 parent 5a82e38 commit 61ef434

13 files changed

+61
-58
lines changed

Diff for: integration-tests/runIntegrationTest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { resolveRelativeFileDependencies } from "../src/resolveRelativeFileDepen
77
export const patchPackageTarballPath = resolve(
88
fs
99
.readdirSync(".")
10-
.filter(nm => nm.match(/^patch-package\.test\.\d+\.tgz$/))[0],
10+
.filter((nm) => nm.match(/^patch-package\.test\.\d+\.tgz$/))[0],
1111
)
1212

1313
export function runIntegrationTest({
@@ -64,7 +64,7 @@ export function runIntegrationTest({
6464
expect(snapshots && snapshots.length).toBeTruthy()
6565
})
6666
if (snapshots) {
67-
snapshots.forEach(snapshot => {
67+
snapshots.forEach((snapshot) => {
6868
const snapshotDescriptionMatch = snapshot.match(/SNAPSHOT: (.*)/)
6969
if (snapshotDescriptionMatch) {
7070
it(snapshotDescriptionMatch[1], () => {

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"jest": "^24.5.0",
7171
"lint-staged": "^8.1.5",
7272
"np": "^6.2.0",
73-
"prettier": "^1.18.2",
73+
"prettier": "^2.1.1",
7474
"randomstring": "^1.1.5",
7575
"ts-jest": "^24.0.0",
7676
"ts-node": "8.0.3",

Diff for: property-based-tests/executeTestCase.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jest.mock("fs-extra", () => {
2424
setWorkingFiles,
2525
getWorkingFiles,
2626
ensureDirSync: jest.fn(),
27-
readFileSync: jest.fn(path => getWorkingFiles()[path].contents),
27+
readFileSync: jest.fn((path) => getWorkingFiles()[path].contents),
2828
writeFileSync: jest.fn(
2929
(path: string, contents: string, opts?: { mode?: number }) => {
3030
getWorkingFiles()[path] = {
@@ -33,12 +33,12 @@ jest.mock("fs-extra", () => {
3333
}
3434
},
3535
),
36-
unlinkSync: jest.fn(path => delete getWorkingFiles()[path]),
36+
unlinkSync: jest.fn((path) => delete getWorkingFiles()[path]),
3737
moveSync: jest.fn((from, to) => {
3838
getWorkingFiles()[to] = getWorkingFiles()[from]
3939
delete getWorkingFiles()[from]
4040
}),
41-
statSync: jest.fn(path => getWorkingFiles()[path]),
41+
statSync: jest.fn((path) => getWorkingFiles()[path]),
4242
chmodSync: jest.fn((path, mode) => {
4343
const { contents } = getWorkingFiles()[path]
4444
getWorkingFiles()[path] = { contents, mode }
@@ -49,7 +49,7 @@ jest.mock("fs-extra", () => {
4949
function writeFiles(cwd: string, files: Files): void {
5050
const mkdirpSync = require("fs-extra/lib/mkdirs/index.js").mkdirpSync
5151
const writeFileSync = require("fs").writeFileSync
52-
Object.keys(files).forEach(filePath => {
52+
Object.keys(files).forEach((filePath) => {
5353
if (!filePath.startsWith(".git/")) {
5454
mkdirpSync(path.join(cwd, path.dirname(filePath)))
5555
writeFileSync(path.join(cwd, filePath), files[filePath].contents, {
@@ -62,7 +62,7 @@ function writeFiles(cwd: string, files: Files): void {
6262
function removeLeadingSpaceOnBlankLines(patchFileContents: string): string {
6363
return patchFileContents
6464
.split("\n")
65-
.map(line => (line === " " ? "" : line))
65+
.map((line) => (line === " " ? "" : line))
6666
.join("\n")
6767
}
6868

Diff for: property-based-tests/testCases.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function insertLinesIntoFile(file: File): File {
121121
function getUniqueFilename(files: Files) {
122122
let filename = makeFileName()
123123
const ks = Object.keys(files)
124-
while (ks.some(k => k.startsWith(filename))) {
124+
while (ks.some((k) => k.startsWith(filename))) {
125125
filename = makeFileName()
126126
}
127127
return filename

Diff for: src/applyPatches.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function applyPatchesForApp({
101101
return
102102
}
103103

104-
files.forEach(filename => {
104+
files.forEach((filename) => {
105105
const packageDetails = getPackageDetailsFromPatchFilename(filename)
106106

107107
if (!packageDetails) {

Diff for: src/filterFiles.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export function removeIgnoredFiles(
88
excludePaths: RegExp,
99
) {
1010
klawSync(dir, { nodir: true })
11-
.map(item => item.path.slice(`${dir}/`.length))
11+
.map((item) => item.path.slice(`${dir}/`.length))
1212
.filter(
13-
relativePath =>
13+
(relativePath) =>
1414
!relativePath.match(includePaths) || relativePath.match(excludePaths),
1515
)
16-
.forEach(relativePath => removeSync(join(dir, relativePath)))
16+
.forEach((relativePath) => removeSync(join(dir, relativePath)))
1717
}

Diff for: src/getPackageResolution.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export function getPackageResolution({
8787
}
8888
lockFileStack.reverse()
8989
const relevantStackEntry = lockFileStack.find(
90-
entry => entry.dependencies && packageDetails.name in entry.dependencies,
90+
(entry) =>
91+
entry.dependencies && packageDetails.name in entry.dependencies,
9192
)
9293
const pkg = relevantStackEntry.dependencies[packageDetails.name]
9394
return pkg.resolved || pkg.from || pkg.version

Diff for: src/makePatch.ts

+3-3
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))
@@ -264,11 +264,11 @@ export function makePatch({
264264
}
265265

266266
const packageNames = packageDetails.packageNames
267-
.map(name => name.replace(/\//g, "+"))
267+
.map((name) => name.replace(/\//g, "+"))
268268
.join("++")
269269

270270
// maybe delete existing
271-
getPatchFiles(patchDir).forEach(filename => {
271+
getPatchFiles(patchDir).forEach((filename) => {
272272
const deets = getPackageDetailsFromPatchFilename(filename)
273273
if (deets && deets.path === packageDetails.path) {
274274
unlinkSync(join(patchDir, filename))

Diff for: 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
}

Diff for: src/patch/apply.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const executeEffects = (
77
effects: ParsedPatchFile,
88
{ dryRun }: { dryRun: boolean },
99
) => {
10-
effects.forEach(eff => {
10+
effects.forEach((eff) => {
1111
switch (eff.type) {
1212
case "file deletion":
1313
if (dryRun) {

Diff for: src/patchFs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const getPatchFiles = (patchesDir: string) => {
55
try {
66
return klawSync(patchesDir, { nodir: true })
77
.map(({ path }) => relative(patchesDir, path))
8-
.filter(path => path.endsWith(".patch"))
8+
.filter((path) => path.endsWith(".patch"))
99
} catch (e) {
1010
return []
1111
}

Diff for: 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+
}

Diff for: 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)