Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e8fb1f
commit f6dc7f9
Showing
4 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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() { | ||
try { | ||
|
||
// First we attempt to find QUnit relative to the current working directory. | ||
const localQUnitPath = resolve.sync( "qunitjs", { basedir: process.cwd() } ); | ||
delete require.cache[ localQUnitPath ]; | ||
return require( localQUnitPath ); | ||
} catch ( e ) { | ||
try { | ||
|
||
// Second, we use the globally installed QUnit | ||
delete require.cache[ require.resolve( "../qunit/qunit" ) ]; | ||
return require( "../qunit/qunit" ); | ||
} catch ( e ) { | ||
if ( e.code === "MODULE_NOT_FOUND" ) { | ||
|
||
// Finally, we use the local development version of QUnit | ||
delete require.cache[ require.resolve( "../dist/qunit" ) ]; | ||
return require( "../dist/qunit" ); | ||
} | ||
|
||
throw e; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters