UNPKG

680 BJavaScriptView Raw
1#!/usr/bin/env zx
2
3const {
4 CI = 'false',
5 INIT_CWD = '',
6} = process.env;
7
8if (CI !== 'true') {
9 const {
10 name: moduleName,
11 } = JSON.parse(await fs.readFile('./package.json', { encoding: 'utf-8' }));
12
13 if (
14 !INIT_CWD.endsWith(`node_modules/${moduleName}`) &&
15 INIT_CWD.endsWith(moduleName)
16 ) {
17 /**
18 * NOTE: To skip running `simple-git-hooks` in CI environment.
19 * But `npm x -y -- simple-git-hooks@latest` does not work as expected so splitting it into
20 * a 2-step process: install without saving as dependency then execute it.
21 */
22 await $`npm i --no-save simple-git-hooks`
23 await $`simple-git-hooks`;
24
25 await $`npm dedupe`;
26 }
27}