Skip to content

Commit efe4734

Browse files
authored
Merge pull request #186 from akd-io/feature/185-npm-i-fails-on-windows-with---format
Fix lint-staged + husky bug on Windows
2 parents a94b2ef + 15564ec commit efe4734

19 files changed

+55
-32
lines changed

packages/create-next-stack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"next": "^13.3.1",
9292
"ts-jest": "^29.1.0",
9393
"ts-node": "^10.9.1",
94+
"typescript": "^4.9.5",
9495
"uuid": "^9.0.0"
9596
}
9697
}

packages/create-next-stack/src/main/plugins/formatting-pre-commit-hook.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ export const formattingPreCommitHookPlugin = createPlugin({
2222
version: "^7.0.0",
2323
},
2424
},
25+
devDependencies: {
26+
"lint-staged": {
27+
name: "lint-staged",
28+
version: ">=10",
29+
},
30+
husky: {
31+
name: "husky",
32+
version: ">=7",
33+
},
34+
},
2535
technologies: [
2636
{
2737
id: "husky",

packages/create-next-stack/src/tests/e2e/helpers/check-formatting-linting-build.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { Options } from "execa"
22
import { runCommand } from "../../../main/helpers/run-command"
33
import { logTestInfo } from "../test-logging"
44

5-
export const checkFormattingLintingBuild = async (
6-
runDirectory: string
5+
export const performE2eChecks = async (
6+
runDirectory: string,
7+
args: string[]
78
): Promise<void> => {
89
const options: Options = {
910
cwd: runDirectory,
@@ -21,4 +22,12 @@ export const checkFormattingLintingBuild = async (
2122

2223
logTestInfo("Running build...")
2324
await runCommand("npm", ["run", "build"], options)
25+
26+
const packageManager = args
27+
.find((arg) => arg.startsWith("--package-manager="))
28+
?.split("=")[1]
29+
if (packageManager) {
30+
logTestInfo("Installing dependencies...")
31+
await runCommand(packageManager, ["install"], options)
32+
}
2433
}

packages/create-next-stack/src/tests/e2e/test-live-cns.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import chalk from "chalk"
22
import endent from "endent"
33
import { v4 as uuidv4 } from "uuid"
44
import { runCommand } from "../../main/helpers/run-command"
5-
import { checkFormattingLintingBuild } from "./helpers/check-formatting-linting-build"
5+
import { performE2eChecks } from "./helpers/check-formatting-linting-build"
66
import { exitWithError } from "./helpers/exit-with-error"
77
import { logTestInfo } from "./test-logging"
88
;(async () => {
@@ -21,7 +21,7 @@ import { logTestInfo } from "./test-logging"
2121

2222
await runCommand(command, args, { stdio: "inherit" })
2323

24-
await checkFormattingLintingBuild(runDirectory)
24+
await performE2eChecks(runDirectory, args)
2525

2626
logTestInfo("")
2727
logTestInfo(endent`

packages/create-next-stack/src/tests/e2e/test-manual.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import chalk from "chalk"
22
import endent from "endent"
33
import { v4 as uuidv4 } from "uuid"
44
import { runCommand } from "../../main/helpers/run-command"
5-
import { checkFormattingLintingBuild } from "./helpers/check-formatting-linting-build"
5+
import { performE2eChecks } from "./helpers/check-formatting-linting-build"
66
import { exitWithError } from "./helpers/exit-with-error"
77
import { logTestInfo } from "./test-logging"
88
;(async () => {
@@ -16,7 +16,7 @@ import { logTestInfo } from "./test-logging"
1616
const args = [...process.argv.slice(2), runDirectory]
1717
await runCommand(pathToCLI, args, { stdio: "inherit" })
1818

19-
await checkFormattingLintingBuild(runDirectory)
19+
await performE2eChecks(runDirectory, args)
2020

2121
logTestInfo("")
2222
logTestInfo(endent`

packages/create-next-stack/src/tests/e2e/tests/css-modules-with-sass/css-modules-with-sass-all-flags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { runCommand } from "../../../../main/helpers/run-command"
2-
import { checkFormattingLintingBuild } from "../../helpers/check-formatting-linting-build"
2+
import { performE2eChecks } from "../../helpers/check-formatting-linting-build"
33
import { logTestMeta } from "../../helpers/log-test-meta"
44
import { minutesToMilliseconds } from "../../helpers/minutes-to-milliseconds"
55
import { prepareE2eTest } from "../../helpers/prepare-e2e-test"
@@ -31,5 +31,5 @@ export const testCssModulesWithSassAllFlags = async (
3131
stderr: "inherit",
3232
})
3333

34-
await checkFormattingLintingBuild(runDirectory)
34+
await performE2eChecks(runDirectory, args)
3535
}

packages/create-next-stack/src/tests/e2e/tests/css-modules-with-sass/css-modules-with-sass-only.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { runCommand } from "../../../../main/helpers/run-command"
2-
import { checkFormattingLintingBuild } from "../../helpers/check-formatting-linting-build"
2+
import { performE2eChecks } from "../../helpers/check-formatting-linting-build"
33
import { logTestMeta } from "../../helpers/log-test-meta"
44
import { minutesToMilliseconds } from "../../helpers/minutes-to-milliseconds"
55
import { prepareE2eTest } from "../../helpers/prepare-e2e-test"
@@ -25,5 +25,5 @@ export const testCssModulesWithSassOnly = async (
2525
stderr: "inherit",
2626
})
2727

28-
await checkFormattingLintingBuild(runDirectory)
28+
await performE2eChecks(runDirectory, args)
2929
}

packages/create-next-stack/src/tests/e2e/tests/css-modules/css-modules-all-flags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { runCommand } from "../../../../main/helpers/run-command"
2-
import { checkFormattingLintingBuild } from "../../helpers/check-formatting-linting-build"
2+
import { performE2eChecks } from "../../helpers/check-formatting-linting-build"
33
import { logTestMeta } from "../../helpers/log-test-meta"
44
import { minutesToMilliseconds } from "../../helpers/minutes-to-milliseconds"
55
import { prepareE2eTest } from "../../helpers/prepare-e2e-test"
@@ -31,5 +31,5 @@ export const testCssModulesAllFlags = async (
3131
stderr: "inherit",
3232
})
3333

34-
await checkFormattingLintingBuild(runDirectory)
34+
await performE2eChecks(runDirectory, args)
3535
}

packages/create-next-stack/src/tests/e2e/tests/css-modules/css-modules-only.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { runCommand } from "../../../../main/helpers/run-command"
2-
import { checkFormattingLintingBuild } from "../../helpers/check-formatting-linting-build"
2+
import { performE2eChecks } from "../../helpers/check-formatting-linting-build"
33
import { logTestMeta } from "../../helpers/log-test-meta"
44
import { minutesToMilliseconds } from "../../helpers/minutes-to-milliseconds"
55
import { prepareE2eTest } from "../../helpers/prepare-e2e-test"
@@ -25,5 +25,5 @@ export const testCssModulesOnly = async (
2525
stderr: "inherit",
2626
})
2727

28-
await checkFormattingLintingBuild(runDirectory)
28+
await performE2eChecks(runDirectory, args)
2929
}

packages/create-next-stack/src/tests/e2e/tests/emotion/emotion-all-flags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { runCommand } from "../../../../main/helpers/run-command"
2-
import { checkFormattingLintingBuild } from "../../helpers/check-formatting-linting-build"
2+
import { performE2eChecks } from "../../helpers/check-formatting-linting-build"
33
import { logTestMeta } from "../../helpers/log-test-meta"
44
import { minutesToMilliseconds } from "../../helpers/minutes-to-milliseconds"
55
import { prepareE2eTest } from "../../helpers/prepare-e2e-test"
@@ -33,5 +33,5 @@ export const testEmotionAllFlags = async (
3333
stderr: "inherit",
3434
})
3535

36-
await checkFormattingLintingBuild(runDirectory)
36+
await performE2eChecks(runDirectory, args)
3737
}

0 commit comments

Comments
 (0)