From 9d3e749104fdeed0f627687d04e95b6fd89e1150 Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:36:54 -0400 Subject: [PATCH] feat(prepare.js): add script to install husky only if NODE_ENV is not 'CI' (#512) refactor(package.json): change prepare script to run prepare.js script instead of husky install directly --- config/prepare.js | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 config/prepare.js diff --git a/config/prepare.js b/config/prepare.js new file mode 100644 index 0000000000..c5ec4ab872 --- /dev/null +++ b/config/prepare.js @@ -0,0 +1,12 @@ +const { exec } = require('child_process'); + +if (process.env.NODE_ENV !== 'CI') { + exec('npx husky install', (error, stdout, stderr) => { + if (error) { + console.error(`exec error: ${error}`); + return; + } + console.log(`stdout: ${stdout}`); + console.error(`stderr: ${stderr}`); + }); +} diff --git a/package.json b/package.json index 0e838d33e6..e347034e59 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "test:api": "cd api && npm run test", "e2e:update": "playwright test --config=e2e/playwright.config.js --update-snapshots", "e2e:report": "npx playwright show-report e2e/playwright-report", - "prepare": "test \"$NODE_ENV\" != \"CI\" && husky install", + "prepare": "node config/prepare.js", "format": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"" }, "repository": {