Skip to content

Commit 979da5d

Browse files
authoredMay 22, 2020
fix: remove nanoid devDependency to remove ExperimentalWarning (#874)
nanoid contains conditional exports and emits a warning on Node.js >= 13.7: `ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time`
1 parent b8e1a4a commit 979da5d

File tree

5 files changed

+26
-58
lines changed

5 files changed

+26
-58
lines changed
 

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"husky": "^4.2.5",
6464
"jest": "^26.0.1",
6565
"jest-snapshot-serializer-ansi": "^1.0.0",
66-
"nanoid": "^3.1.7",
6766
"prettier": "^2.0.5"
6867
},
6968
"config": {

‎test/gitWorkflow.spec.js

+4-25
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,18 @@
11
import fs from 'fs-extra'
2-
import { nanoid } from 'nanoid'
32
import normalize from 'normalize-path'
4-
import os from 'os'
53
import path from 'path'
64

75
import execGitBase from '../lib/execGit'
86
import { writeFile } from '../lib/file'
97
import GitWorkflow from '../lib/gitWorkflow'
108
import { getInitialState } from '../lib/state'
9+
import { createTempDir } from './utils/tempDir'
1110

1211
jest.mock('../lib/file.js')
1312
jest.unmock('execa')
1413

1514
jest.setTimeout(20000)
1615

17-
const isAppveyor = !!process.env.APPVEYOR
18-
const osTmpDir = isAppveyor ? 'C:\\projects' : fs.realpathSync(os.tmpdir())
19-
20-
/**
21-
* Create temporary directory and return its path
22-
* @returns {Promise<String>}
23-
*/
24-
const createTempDir = async () => {
25-
const dirname = path.resolve(osTmpDir, 'lint-staged-test', nanoid())
26-
await fs.ensureDir(dirname)
27-
return dirname
28-
}
29-
30-
/**
31-
* Remove temporary directory
32-
* @param {String} dirname
33-
* @returns {Promise<Void>}
34-
*/
35-
const removeTempDir = async (dirname) => {
36-
await fs.remove(dirname)
37-
}
38-
3916
let tmpDir, cwd
4017

4118
/** Append to file, creating if it doesn't exist */
@@ -55,6 +32,8 @@ const initGitRepo = async () => {
5532
await execGit(['commit', '-m initial commit'])
5633
}
5734

35+
const isAppveyor = !!process.env.APPVEYOR
36+
5837
describe('gitWorkflow', () => {
5938
beforeEach(async () => {
6039
tmpDir = await createTempDir()
@@ -64,7 +43,7 @@ describe('gitWorkflow', () => {
6443

6544
afterEach(async () => {
6645
if (!isAppveyor) {
67-
await removeTempDir(tmpDir)
46+
await fs.remove(tmpDir)
6847
}
6948
})
7049

‎test/integration.test.js

+6-27
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import makeConsoleMock from 'consolemock'
22
import fs from 'fs-extra'
33
import ansiSerializer from 'jest-snapshot-serializer-ansi'
4-
import { nanoid } from 'nanoid'
54
import normalize from 'normalize-path'
6-
import os from 'os'
75
import path from 'path'
86

97
jest.unmock('cosmiconfig')
@@ -12,6 +10,7 @@ jest.unmock('execa')
1210
import execGitBase from '../lib/execGit'
1311
import lintStaged from '../lib/index'
1412
import { replaceSerializer } from './utils/replaceSerializer'
13+
import { createTempDir } from './utils/tempDir'
1514

1615
jest.setTimeout(20000)
1716

@@ -31,28 +30,6 @@ const testJsFileUnfixable = `const obj = {
3130

3231
const fixJsConfig = { config: { '*.js': 'prettier --write' } }
3332

34-
const isAppveyor = !!process.env.APPVEYOR
35-
const osTmpDir = isAppveyor ? 'C:\\projects' : fs.realpathSync(os.tmpdir())
36-
37-
/**
38-
* Create temporary directory and return its path
39-
* @returns {Promise<String>}
40-
*/
41-
const createTempDir = async () => {
42-
const dirname = path.resolve(osTmpDir, 'lint-staged-test', nanoid())
43-
await fs.ensureDir(dirname)
44-
return dirname
45-
}
46-
47-
/**
48-
* Remove temporary directory
49-
* @param {String} dirname
50-
* @returns {Promise<Void>}
51-
*/
52-
const removeTempDir = async (dirname) => {
53-
await fs.remove(dirname)
54-
}
55-
5633
let tmpDir
5734
let cwd
5835

@@ -90,7 +67,7 @@ describe('lint-staged', () => {
9067
"
9168
ERROR × Current directory is not a git directory!"
9269
`)
93-
await removeTempDir(nonGitDir)
70+
await fs.remove(nonGitDir)
9471
})
9572

9673
it('should fail without output when not in a git directory and quiet', async () => {
@@ -100,12 +77,14 @@ describe('lint-staged', () => {
10077
lintStaged({ ...fixJsConfig, cwd: nonGitDir, quiet: true }, logger)
10178
).resolves.toEqual(false)
10279
expect(logger.printHistory()).toMatchInlineSnapshot(`""`)
103-
await removeTempDir(nonGitDir)
80+
await fs.remove(nonGitDir)
10481
})
10582
})
10683

10784
const globalConsoleTemp = console
10885

86+
const isAppveyor = !!process.env.APPVEYOR
87+
10988
describe('lint-staged', () => {
11089
beforeAll(() => {
11190
console = makeConsoleMock()
@@ -126,7 +105,7 @@ describe('lint-staged', () => {
126105
afterEach(async () => {
127106
console.clearHistory()
128107
if (!isAppveyor) {
129-
await removeTempDir(tmpDir)
108+
await fs.remove(tmpDir)
130109
}
131110
})
132111

‎test/utils/tempDir.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import fs from 'fs-extra'
2+
import os from 'os'
3+
import path from 'path'
4+
5+
const osTmpDir = process.env.APPVEYOR ? 'C:\\projects' : fs.realpathSync(os.tmpdir())
6+
7+
/**
8+
* Create temporary random directory and return its path
9+
* @returns {Promise<String>}
10+
*/
11+
export const createTempDir = async () => {
12+
const random = Date.now().toString(36) + Math.random().toString(36).substr(2)
13+
const dirname = path.resolve(osTmpDir, `lint-staged-${random}`)
14+
await fs.ensureDir(dirname)
15+
return dirname
16+
}

‎yarn.lock

-5
Original file line numberDiff line numberDiff line change
@@ -4078,11 +4078,6 @@ mute-stream@0.0.8:
40784078
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
40794079
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==
40804080

4081-
nanoid@^3.1.7:
4082-
version "3.1.7"
4083-
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.7.tgz#3705ccf590b6a51fbd1794fcf204ce7b5dc46c01"
4084-
integrity sha512-ruOwuatdEf4BxQmZopZqhIMudQ9V83aKocr+q2Y7KasnDNvo2OgbgZBYago5hSD0tCmoSl4flIw9ytDLIVM2IQ==
4085-
40864081
nanomatch@^1.2.9:
40874082
version "1.2.13"
40884083
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"

0 commit comments

Comments
 (0)
Please sign in to comment.