Skip to content

Commit

Permalink
fix: read version number from lint-staged package.json instead of pac…
Browse files Browse the repository at this point in the history
…kage.json in cwd (#1043) (#1044)

If the package.json did not have a version number, it would cause lint-staged to crash.
  • Loading branch information
coalman authored Nov 13, 2021
1 parent 7240f61 commit 9f9213d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/lint-staged.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node

import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

import cmdline from 'commander'
import debug from 'debug'
Expand All @@ -17,7 +19,8 @@ if (supportsColor.stdout) {
// Do not terminate main Listr process on SIGINT
process.on('SIGINT', () => {})

const packageJson = JSON.parse(fs.readFileSync('package.json'))
const packageJsonPath = path.join(fileURLToPath(import.meta.url), '../../package.json')
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))
const version = packageJson.version

cmdline
Expand Down

0 comments on commit 9f9213d

Please sign in to comment.