Browse Source

Account for gitignores when running `git add`

Renée Kooi 5 years ago
parent
commit
999253f034
1 changed files with 7 additions and 3 deletions
  1. 7 3
      bin/after-version-bump.js

+ 7 - 3
bin/after-version-bump.js

@@ -46,12 +46,13 @@ async function updateVersions (files, packageName) {
 
 async function gitAdd (files) {
   const git = spawn('git', ['add', ...files], { stdio: 'inherit' })
-  const exitCode = await once(git, 'exit')
+  const [exitCode] = await once(git, 'exit')
   if (exitCode !== 0) {
     throw new Error(`git add failed with ${exitCode}`)
   }
 }
 
+// Run the build as a release build (that inlines version numbers etc.)
 async function npmRunBuild () {
   const npmRun = spawn('npm', ['run', 'build'], {
     stdio: 'inherit',
@@ -60,7 +61,7 @@ async function npmRunBuild () {
       IS_RELEASE_BUILD: true
     }
   })
-  const exitCode = await once(npmRun, 'exit')
+  const [exitCode] = await once(npmRun, 'exit')
   if (exitCode !== 0) {
     throw new Error(`npm run build failed with ${exitCode}`)
   }
@@ -93,7 +94,10 @@ async function main () {
   await updateVersions(files, '@uppy/robodog')
   await updateVersions(files, '@uppy/locales')
 
-  await gitAdd(files)
+  // gitignored files were updated for the npm package, but can't be updated
+  // on git.
+  const isIgnored = await globby.gitignore()
+  await gitAdd(files.filter((filename) => !isIgnored(filename)))
 
   await npmRunBuild()
 }