-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.js
27 lines (23 loc) · 1.4 KB
/
ci.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { resolve } from 'node:path'
import { arch, release, userInfo } from 'node:os'
import { withFallbackResult } from '@dr-js/core/module/common/error.js'
import { getPathNpm } from '@dr-js/core/module/node/module/Software/npm.js'
const runInfoPatchCombo = ({ RUN, padLog, log }) => {
padLog('Log info')
log(`system: ${process.platform}-${release()}[${arch()}]`)
const { username = '???', uid = process.getuid(), gid = process.getgid() } = withFallbackResult({}, userInfo) // may throw in docker with uid-only-user: `SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_get_passwd returned ENOENT`
log(`user: ${username} [${uid}-${gid}]`)
log(`node: ${process.version}`)
log(`npm: ${require(resolve(getPathNpm(), './package.json')).version}`)
log(`with: ${[ '@dr-js/core', '@dr-js/dev' ].map((v) => `${v}@${require(`${v}/package.json`).version}`).join(', ')}`)
if (process.platform === 'win32') {
padLog('Patch git') // fix win32 CI cause `something to commit` test error: https://github.com/actions/checkout/issues/135#issuecomment-602171132
RUN('git config core.autocrlf false')
RUN('git config core.eol lf')
RUN('git rm --cached -r .') // reset Git index, `rm .git/index` also work, check: https://stackoverflow.com/questions/5787937/git-status-shows-files-as-changed-even-though-contents-are-the-same/41041699#41041699
RUN('git reset --hard')
}
}
export {
runInfoPatchCombo
}