diff --git a/integration-tests/happy-path-npm/__snapshots__/happy-path-npm.test.ts.snap b/integration-tests/happy-path-npm/__snapshots__/happy-path-npm.test.ts.snap index df4004bd..393b4773 100644 --- a/integration-tests/happy-path-npm/__snapshots__/happy-path-npm.test.ts.snap +++ b/integration-tests/happy-path-npm/__snapshots__/happy-path-npm.test.ts.snap @@ -2,6 +2,7 @@ exports[`Test happy-path-npm: making patch 1`] = ` "SNAPSHOT: making patch +patch-package 0.0.0 ✔ Creating temporary folder ✔ Making tmp package.json ✔ Installing left-pad@1.1.3 with npm diff --git a/integration-tests/happy-path-yarn/__snapshots__/happy-path-yarn.test.ts.snap b/integration-tests/happy-path-yarn/__snapshots__/happy-path-yarn.test.ts.snap index eaec9d92..4fdf6a29 100644 --- a/integration-tests/happy-path-yarn/__snapshots__/happy-path-yarn.test.ts.snap +++ b/integration-tests/happy-path-yarn/__snapshots__/happy-path-yarn.test.ts.snap @@ -2,6 +2,7 @@ exports[`Test happy-path-yarn: making patch 1`] = ` "SNAPSHOT: making patch +patch-package 0.0.0 ✔ Creating temporary folder ✔ Making tmp package.json ✔ Installing left-pad@1.1.3 with yarn diff --git a/integration-tests/nested-packages/__snapshots__/nested-packages.test.ts.snap b/integration-tests/nested-packages/__snapshots__/nested-packages.test.ts.snap index 16210035..ccbd11aa 100644 --- a/integration-tests/nested-packages/__snapshots__/nested-packages.test.ts.snap +++ b/integration-tests/nested-packages/__snapshots__/nested-packages.test.ts.snap @@ -2,6 +2,7 @@ exports[`Test nested-packages: create the patch 1`] = ` "SNAPSHOT: create the patch +patch-package 0.0.0 ✔ Creating temporary folder ✔ Making tmp package.json ✔ Installing string-width@2.1.1 with yarn @@ -12,7 +13,8 @@ END SNAPSHOT" exports[`Test nested-packages: run patch-package 1`] = ` "SNAPSHOT: run patch-package -patch-package: Applying patches... +patch-package 0.0.0 +Applying patches... wrap-ansi/string-width@2.1.1 ✔ END SNAPSHOT" `; diff --git a/integration-tests/nested-scoped-packages/__snapshots__/nested-scoped-packages.test.ts.snap b/integration-tests/nested-scoped-packages/__snapshots__/nested-scoped-packages.test.ts.snap index 277224b2..b29d81ca 100644 --- a/integration-tests/nested-scoped-packages/__snapshots__/nested-scoped-packages.test.ts.snap +++ b/integration-tests/nested-scoped-packages/__snapshots__/nested-scoped-packages.test.ts.snap @@ -2,6 +2,7 @@ exports[`Test nested-scoped-packages: create the patch 1`] = ` "SNAPSHOT: create the patch +patch-package 0.0.0 ✔ Creating temporary folder ✔ Making tmp package.json ✔ Installing @types/angular@1.6.53 with yarn @@ -12,7 +13,8 @@ END SNAPSHOT" exports[`Test nested-scoped-packages: run patch-package 1`] = ` "SNAPSHOT: run patch-package -patch-package: Applying patches... +patch-package 0.0.0 +Applying patches... @microsoft/mezzurite-core/@types/angular@1.6.53 ✔ END SNAPSHOT" `; diff --git a/run-tests.sh b/run-tests.sh index 4753051a..894d5268 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -5,5 +5,8 @@ export CI=true yarn clean yarn build +version=$(node -e 'console.log(require("./package.json").version)') +yarn version --new-version 0.0.0 --no-git-tag-version --no-commit-hooks yarn pack --filename patch-package.test.$(date +%s).tgz -jest "$@" +yarn version --new-version $version --no-git-tag-version --no-commit-hooks +yarn jest "$@" diff --git a/src/applyPatches.ts b/src/applyPatches.ts index 87c51c82..e71f7c59 100644 --- a/src/applyPatches.ts +++ b/src/applyPatches.ts @@ -1,4 +1,4 @@ -import { bold, cyan, green, red, yellow } from "chalk" +import { bold, green, red, yellow } from "chalk" import { getPatchFiles } from "./patchFs" import { executeEffects } from "./patch/apply" import { existsSync, readFileSync } from "fs-extra" @@ -48,7 +48,8 @@ export const applyPatchesForApp = ( const files = findPatchFiles(patchesDirectory) if (files.length === 0) { - console.log(cyan("No patch files found")) + console.error(red("No patch files found")) + process.exit(1) } files.forEach(filename => { diff --git a/src/index.ts b/src/index.ts index 00fa02f9..b204a28b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ import { getAppRootPath } from "./getAppRootPath" import { makePatch } from "./makePatch" import { makeRegExp } from "./makeRegExp" import { detectPackageManager } from "./detectPackageManager" +import { join } from "./path" const appPath = getAppRootPath() const argv = minimist(process.argv.slice(2), { @@ -15,6 +16,12 @@ const argv = minimist(process.argv.slice(2), { }) const packageNames = argv._ +console.log( + bold("patch-package"), + // tslint:disable-next-line:no-var-requires + require(join(__dirname, "../package.json")).version, +) + if (argv.help || argv.h) { printHelp() } else { @@ -42,7 +49,7 @@ if (argv.help || argv.h) { ) }) } else { - console.log("patch-package: Applying patches...") + console.log("Applying patches...") applyPatchesForApp(appPath, !!argv["reverse"], argv["patch-dir"]) } }