Skip to content

Cannot run CI compatible install script #1356

@starnayuta

Description

@starnayuta

The installation scripts compatible with CI need to be modified for these reasons.

Must indicate ES Modules because it uses top-level await

PS C:path\to\directory> npm i

> directory@1.0.0 prepare
> node .husky/install.js

C:path\to\directory\.husky\install.js:5
const husky = await import('husky')
              ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules
    at internalCompileFunction (node:internal/vm:77:18)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.11.0
npm ERR! code 1
npm ERR! path C:\path\to\directory
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node .husky/install.js

husky() is not a function, so it must use husky.default()

PS C:path\to\directory> npm i

> directory@1.0.0 prepare
> node .husky/install.mjs
file:///C:/path/to/directory/.husky/install.mjs:6
husky()
^

TypeError: husky is not a function
    at file:///C:/path/to/directory/.husky/install.mjs:6:1

Node.js v20.11.0
npm ERR! code 1
npm ERR! path C:path\to\directory
npm ERR! command failed

CI checks should be fixed

According to ci-info, when we use process.env.CI, we should use !!(process.env.CI !== 'false' && process.env.CI).

https://github.com/watson/ci-info/blob/v4.0.0/index.js#L56-L69

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions