Skip to content

Commit

Permalink
chore: dont run git commands when not in git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Nov 9, 2022
1 parent 42325be commit 7a5fd01
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/bundle-and-gitignore-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { join, relative } = require('path')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const PackageJson = require('@npmcli/package-json')
const { run, CWD, git, fs } = require('./util')
const npmGit = require('@npmcli/git')

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

if (!await npmGit.is({ cwd: CWD })) {
// if we are not running in a git repo then write the files but we do not
// need to run any git commands to check if we have unmatched files in source
return res
}

// After we write the file we have to check if any of the paths already checked in
// inside node_modules are now going to be ignored. If we find any then fail with
// a list of the paths remaining. We already attempted to `git rm` them so just
Expand Down

0 comments on commit 7a5fd01

Please sign in to comment.