lint-staged 10.0.6 → 10.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/file.js CHANGED
@@ -1,7 +1,13 @@
1
1
  'use strict'
2
2
 
3
3
  const debug = require('debug')('lint-staged:file')
4
- const fs = require('fs').promises
4
+ const fs = require('fs')
5
+ const { promisify } = require('util')
6
+
7
+ const fsAccess = promisify(fs.access)
8
+ const fsReadFile = promisify(fs.readFile)
9
+ const fsUnlink = promisify(fs.unlink)
10
+ const fsWriteFile = promisify(fs.writeFile)
5
11
 
6
12
  /**
7
13
  * Check if a file exists. Returns the filename if exists.
@@ -10,7 +16,7 @@ const fs = require('fs').promises
10
16
  */
11
17
  const exists = async filename => {
12
18
  try {
13
- await fs.access(filename)
19
+ await fsAccess(filename)
14
20
  return filename
15
21
  } catch {
16
22
  return false
@@ -26,7 +32,7 @@ const exists = async filename => {
26
32
  const readFile = async (filename, ignoreENOENT = true) => {
27
33
  debug('Reading file `%s`', filename)
28
34
  try {
29
- return await fs.readFile(filename)
35
+ return await fsReadFile(filename)
30
36
  } catch (error) {
31
37
  if (ignoreENOENT && error.code === 'ENOENT') {
32
38
  debug("File `%s` doesn't exist, ignoring...", filename)
@@ -46,7 +52,7 @@ const unlink = async (filename, ignoreENOENT = true) => {
46
52
  if (filename) {
47
53
  debug('Unlinking file `%s`', filename)
48
54
  try {
49
- await fs.unlink(filename)
55
+ await fsUnlink(filename)
50
56
  } catch (error) {
51
57
  if (ignoreENOENT && error.code === 'ENOENT') {
52
58
  debug("File `%s` doesn't exist, ignoring...", filename)
@@ -64,7 +70,7 @@ const unlink = async (filename, ignoreENOENT = true) => {
64
70
  */
65
71
  const writeFile = async (filename, buffer) => {
66
72
  debug('Writing file `%s`', filename)
67
- await fs.writeFile(filename, buffer)
73
+ await fsWriteFile(filename, buffer)
68
74
  }
69
75
 
70
76
  module.exports = {
@@ -1,21 +1,23 @@
1
1
  'use strict'
2
2
 
3
3
  const normalize = require('normalize-path')
4
- const fs = require('fs').promises
5
- const path = require('path')
6
-
7
4
  const debugLog = require('debug')('lint-staged:resolveGitRepo')
5
+ const fs = require('fs')
6
+ const path = require('path')
7
+ const { promisify } = require('util')
8
8
 
9
9
  const execGit = require('./execGit')
10
10
  const { readFile } = require('./file')
11
11
 
12
+ const fsLstat = promisify(fs.lstat)
13
+
12
14
  /**
13
15
  * Resolve path to the .git directory, with special handling for
14
16
  * submodules and worktrees
15
17
  */
16
18
  const resolveGitConfigDir = async gitDir => {
17
19
  const defaultDir = path.resolve(gitDir, '.git')
18
- const stats = await fs.lstat(defaultDir)
20
+ const stats = await fsLstat(defaultDir)
19
21
  // If .git is a directory, use it
20
22
  if (stats.isDirectory()) return defaultDir
21
23
  // Otherwise .git is a file containing path to real location
@@ -26,7 +28,7 @@ const resolveGitConfigDir = async gitDir => {
26
28
  /**
27
29
  * Resolve git directory and possible submodule paths
28
30
  */
29
- module.exports = async function resolveGitRepo(cwd) {
31
+ const resolveGitRepo = async cwd => {
30
32
  try {
31
33
  debugLog('Resolving git repo from `%s`', cwd)
32
34
  // git cli uses GIT_DIR to fast track its response however it might be set to a different path
@@ -46,3 +48,5 @@ module.exports = async function resolveGitRepo(cwd) {
46
48
  return { error, gitDir: null, gitConfigDir: null }
47
49
  }
48
50
  }
51
+
52
+ module.exports = resolveGitRepo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "10.0.6",
3
+ "version": "10.0.7",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",