Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Drop support for Node 6 and Node 8, require Node 10+ #1464

Merged
merged 1 commit into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist
node_modules
build/report
browserstack-run.pid
temp/
docs/_site/
/dist
/node_modules
/build/report
/browserstack-run.pid
/temp/
/docs/_site/

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ node_js:
- "14"
- "12"
- "10"
- "8"
- "6"
env:
- NPM_SCRIPT=test
matrix:
Expand Down
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
],
"main": "qunit/qunit.js",
"engines": {
"node": ">=6"
"node": ">=10"
},
"dependencies": {
"commander": "2.12.2",
"js-reporters": "1.2.1",
"resolve": "1.9.0",
"node-watch": "0.6.4",
"minimatch": "3.0.4"
},
Expand Down
6 changes: 1 addition & 5 deletions src/cli/require-from-cwd.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const resolve = require( "resolve" );

module.exports = function requireFromCWD( mod ) {

// TODO: Once Node 8+ is required, consider using native require.resolve().
const resolvedPath = resolve.sync( mod, { basedir: process.cwd() } );
const resolvedPath = require.resolve( mod, { paths: [ process.cwd() ] } );
return require( resolvedPath );
};
10 changes: 4 additions & 6 deletions src/cli/require-qunit.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
const resolve = require( "resolve" );

// Depending on the exact usage, QUnit could be in one of several places, this
// function handles finding it.
module.exports = function requireQUnit() {
module.exports = function requireQUnit( resolve = require.resolve ) {
try {

// First we attempt to find QUnit relative to the current working directory.
const localQUnitPath = resolve.sync( "qunit", { basedir: process.cwd() } );
const localQUnitPath = resolve( "qunit", { paths: [ process.cwd() ] } );
delete require.cache[ localQUnitPath ];
return require( localQUnitPath );
} catch ( e ) {
try {

// Second, we use the globally installed QUnit
delete require.cache[ resolve.sync( "../../qunit/qunit" ) ];
delete require.cache[ resolve( "../../qunit/qunit" ) ];
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
return require( "../../qunit/qunit" );
} catch ( e ) {
if ( e.code === "MODULE_NOT_FOUND" ) {

// Finally, we use the local development version of QUnit
delete require.cache[ resolve.sync( "../../dist/qunit" ) ];
delete require.cache[ resolve( "../../dist/qunit" ) ];
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
return require( "../../dist/qunit" );
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions test/cli/require-qunit-test.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
const proxyquire = require( "proxyquire" );
const resolveStub = {
sync( path ) {
return path;
}
const proxyquire = require( "proxyquire" ).noCallThru();
const path = require( "path" );
const resolveStub = ( path ) => {
return path;
};

QUnit.module( "requireQUnit", function() {
QUnit.module( "requireQUnit", function( hooks ) {
const cwd = process.cwd();

hooks.before( () => {
process.chdir( cwd );
} );
hooks.afterEach( () => {
process.chdir( cwd );
} );

QUnit.test( "finds QUnit in the current working directory", function( assert ) {
const localQUnit = {
"@noCallThru": true
};
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": localQUnit
} );
const requireQUnit = require( "../../src/cli/require-qunit" );
process.chdir( path.join( __dirname, "./fixtures/require-from-cwd" ) );

assert.strictEqual( requireQUnit(), localQUnit );
assert.propEqual( requireQUnit(), { version: "from-cwd" } );
} );

QUnit.test( "finds globally installed QUnit", function( assert ) {
const globalQUnit = {
"@noCallThru": true
"version": "from-global"
};
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": null,
"../../dist/qunit": null,
"../../qunit/qunit": globalQUnit
} );

assert.strictEqual( requireQUnit(), globalQUnit );
assert.strictEqual( requireQUnit( resolveStub ), globalQUnit );
} );

QUnit.test( "finds development mode QUnit", function( assert ) {
const devQUnit = {
"@noCallThru": true
"version": "from-dist"
};
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": null,
"../../qunit/qunit": null,
"../../dist/qunit": devQUnit
} );

assert.strictEqual( requireQUnit(), devQUnit );
assert.strictEqual( requireQUnit( resolveStub ), devQUnit );
} );

QUnit.test( "throws error if none of the modules are found", function( assert ) {
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"resolve": resolveStub,
"qunit": null,
"../../qunit/qunit": null,
"../../dist/qunit": null
Expand Down