Skip to content

Commit 26c72d0

Browse files
authored
Merge pull request #1729 from yunnysunny/feat/old-node
Re-enable the test for old Node
2 parents 4f043a8 + 18896ec commit 26c72d0

File tree

7 files changed

+181
-124
lines changed

7 files changed

+181
-124
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
3535
- name: Install Dependencies On Old Node ${{ matrix.node-version }}
3636
if: ${{ matrix.test-on-old-node == '1' }}
37-
run: yarn install --ignore-optional --ignore-scripts
37+
run: node ci/remove-deps-4-old-node.js && yarn install --ignore-scripts
3838
- name: Install Dependencies On Node ${{ matrix.node-version }}
3939
if: ${{ matrix.test-on-old-node != '1' }}
4040
run: yarn install

.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
yarn lint-staged && yarn test
4+
yarn test

ci/remove-deps-4-old-node.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const package = require('../package.json');
4+
5+
const UNSUPPORT_DEPS_4_OLD = new Set([
6+
'@commitlint/cli',
7+
'@commitlint/config-conventional',
8+
'eslint',
9+
'eslint-config-xo-lass',
10+
'eslint-plugin-compat',
11+
'eslint-plugin-node',
12+
'husky',
13+
'lint-staged',
14+
'remark-cli',
15+
'remark-preset-github',
16+
'xo'
17+
]);
18+
19+
for (const item in package.devDependencies) {
20+
if (UNSUPPORT_DEPS_4_OLD.has(item)) {
21+
package.devDependencies[item] = undefined;
22+
}
23+
}
24+
25+
fs.writeFileSync(
26+
path.join(__dirname, '../package.json'),
27+
JSON.stringify(package, null, 2)
28+
);

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"@babel/plugin-transform-runtime": "^7.18.2",
3838
"@babel/preset-env": "^7.18.2",
3939
"@babel/runtime": "^7.18.3",
40-
"@commitlint/cli": "^17.0.2",
41-
"@commitlint/config-conventional": "^17.0.2",
40+
"@commitlint/cli": "^16.3.0",
41+
"@commitlint/config-conventional": "^16.2.4",
4242
"Base64": "^1.1.0",
4343
"babelify": "^10.0.0",
4444
"basic-auth-connect": "^1.0.0",
@@ -55,7 +55,7 @@
5555
"express-session": "^1.17.3",
5656
"fixpack": "^4.0.0",
5757
"get-port": "4.2.0",
58-
"husky": "^8.0.1",
58+
"husky": "^7.0.4",
5959
"lint-staged": "^12.5.0",
6060
"marked": "^2.0.0",
6161
"mocha": "6.2.2",

test/node/multipart.js

+27-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function getFullPath(filename) {
1919
}
2020

2121
const fullPath = path.join(__dirname, '../../', filename);
22-
return fullPath.charAt(0).toLowerCase() + fullPath.slice(1);
22+
return fullPath;
2323
}
2424

2525
describe('Multipart', () => {
@@ -104,7 +104,14 @@ describe('Multipart', () => {
104104
assert.ok(Boolean(error), 'Request should have failed.');
105105
error.code.should.equal('ENOENT');
106106
error.message.should.containEql('ENOENT');
107-
error.path.should.equal(getFullPath('foo'));
107+
if (IS_WINDOWS) {
108+
error.path.toLowerCase().should.equal(
109+
getFullPath('foo').toLowerCase()
110+
);
111+
} else {
112+
error.path.should.equal(getFullPath('foo'));
113+
}
114+
108115
done();
109116
});
110117
});
@@ -118,7 +125,14 @@ describe('Multipart', () => {
118125
(res) => assert.fail('It should not allow this'),
119126
(err) => {
120127
err.code.should.equal('ENOENT');
121-
err.path.should.equal(getFullPath('does-not-exist.txt'));
128+
if (IS_WINDOWS) {
129+
err.path.toLowerCase().should.equal(
130+
getFullPath('does-not-exist.txt').toLowerCase()
131+
);
132+
} else {
133+
err.path.should.equal(getFullPath('does-not-exist.txt'));
134+
}
135+
122136
}
123137
);
124138
});
@@ -190,9 +204,16 @@ describe('Multipart', () => {
190204
.end((error, res) => {
191205
assert.ok(Boolean(error), 'Request should have failed.');
192206
error.code.should.equal('ENOENT');
193-
error.path.should.equal(
194-
getFullPath('test/node/fixtures/non-existent-file.ext')
195-
);
207+
if (IS_WINDOWS) {
208+
error.path.toLowerCase().should.equal(
209+
getFullPath('test/node/fixtures/non-existent-file.ext').toLowerCase()
210+
);
211+
} else {
212+
error.path.should.equal(
213+
getFullPath('test/node/fixtures/non-existent-file.ext')
214+
);
215+
}
216+
196217
done();
197218
});
198219
});

test/node/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
'use strict';
22
const assert = require('assert');
3-
const utils = require('../../lib/utils');
3+
const utils =
4+
process.env.OLD_NODE_TEST === '1'
5+
// eslint-disable-next-line node/no-missing-require
6+
? require('../../../utils')
7+
: require('../../lib/utils');
48

59
describe('utils.type(str)', () => {
610
it('should return the mime type', () => {

0 commit comments

Comments
 (0)