Skip to content

Commit fd856d3

Browse files
committed
chore: dont run git commands when not in git repo
1 parent 46b2728 commit fd856d3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/bundle-and-gitignore-deps.js

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { join, relative } = require('path')
44
const localeCompare = require('@isaacs/string-locale-compare')('en')
55
const PackageJson = require('@npmcli/package-json')
66
const { run, CWD, git, fs } = require('./util')
7+
const npmGit = require('@npmcli/git')
78

89
const ALWAYS_IGNORE = `
910
.bin/
@@ -227,6 +228,12 @@ const main = async () => {
227228
const NODE_MODULES = join(CWD, 'node_modules')
228229
const res = await fs.writeFile(join(NODE_MODULES, '.gitignore'), ignoreFile.join('\n'))
229230

231+
if (!await npmGit.is({ cwd: CWD })) {
232+
// if we are not running in a git repo then write the files but we do not
233+
// need to run any git commands to check if we have unmatched files in source
234+
return res
235+
}
236+
230237
// After we write the file we have to check if any of the paths already checked in
231238
// inside node_modules are now going to be ignored. If we find any then fail with
232239
// a list of the paths remaining. We already attempted to `git rm` them so just

0 commit comments

Comments
 (0)