Skip to content

fail if no patches are present #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] with npm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] with yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] with yarn
Expand All @@ -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/[email protected]
END SNAPSHOT"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected] with yarn
Expand All @@ -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/[email protected]
END SNAPSHOT"
`;
5 changes: 4 additions & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
5 changes: 3 additions & 2 deletions src/applyPatches.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 => {
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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), {
Expand All @@ -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 {
Expand Down Expand Up @@ -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"])
}
}
Expand Down