Last active
March 18, 2022 21:44
-
-
Save paul-vd/dbcc56a181a52d6b794cf9e2c7928fb2 to your computer and use it in GitHub Desktop.
git-diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ABORT_BUILD_CODE = 0; | |
const CONTINUE_BUILD_CODE = 1; | |
const continueBuild = () => { | |
console.log("🟢 - building"); | |
process.exit(CONTINUE_BUILD_CODE); | |
}; | |
const abortBuild = (reason) => { | |
console.log("⚪️ - build canceled :", reason); | |
process.exit(ABORT_BUILD_CODE); | |
}; | |
const currentApp = process.cwd().split("/").pop(); | |
/** | |
* This checks if there are any changes in the folder for the targeted application | |
*/ | |
const checkGitDiff = () => { | |
if (!currentApp || !fs.existsSync(fromRootPath(`./apps/${currentApp}`))) { | |
abortBuild("app not found"); | |
} | |
const diffInApp = Number( | |
childProcess | |
.execSync(`git diff --name-only HEAD^ HEAD ${appPath} | wc -l`) | |
.toString() | |
.replace("\n", "") | |
); | |
return diffInApp ? true : abortBuild("no changes in app"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment