Comparing version 5.0.1 to 5.1.0
const path = require('path'); | ||
const url = require('url'); | ||
@@ -14,13 +15,4 @@ class Loader { | ||
if ((this.alwaysImport && !modulePath.endsWith('.json')) || modulePath.endsWith('.mjs')) { | ||
let importSpecifier; | ||
const importSpecifier = this.resolveImportSpecifier_(modulePath); | ||
if (modulePath.indexOf(path.sep) === -1 && modulePath.indexOf('/') === -1) { | ||
importSpecifier = modulePath; | ||
} else { | ||
// The ES module spec requires import paths to be valid URLs. As of v14, | ||
// Node enforces this on Windows but not on other OSes. On OS X, import | ||
// paths that are URLs must not contain parent directory references. | ||
importSpecifier = `file://${this.resolvePath_(modulePath)}`; | ||
} | ||
return this.import_(importSpecifier) | ||
@@ -51,2 +43,21 @@ .then( | ||
} | ||
resolveImportSpecifier_(modulePath) { | ||
const isNamespaced = modulePath.startsWith('@'); | ||
const isRelative = modulePath.startsWith('.'); | ||
const hasExtension = /\.[A-Za-z]+/.test(modulePath); | ||
const resolvedModulePath = hasExtension || isRelative | ||
? this.resolvePath_(modulePath) | ||
: modulePath; | ||
if (isNamespaced || ! hasExtension) { | ||
return resolvedModulePath; | ||
} | ||
// The ES module spec requires import paths to be valid URLs. As of v14, | ||
// Node enforces this on Windows but not on other OSes. On OS X, import | ||
// paths that are URLs must not contain parent directory references. | ||
return url.pathToFileURL(resolvedModulePath).toString(); | ||
} | ||
} | ||
@@ -53,0 +64,0 @@ |
@@ -81,7 +81,12 @@ const path = require('path'); | ||
} else { | ||
let numFound = 0; | ||
for (const ext of ['json', 'js']) { | ||
try { | ||
await this.loadSpecificConfigFile_(`spec/support/jasmine.${ext}`); | ||
numFound++; | ||
} catch (e) { | ||
if (e.code !== 'MODULE_NOT_FOUND' && e.code !== 'ERR_MODULE_NOT_FOUND') { | ||
if (e.code !== 'MODULE_NOT_FOUND' // CommonJS | ||
&& e.code !== 'ERR_MODULE_NOT_FOUND' // ESM | ||
&& e.code !== 'ENOENT') { // Testdouble.js, maybe other ESM loaders too | ||
throw e; | ||
@@ -91,2 +96,11 @@ } | ||
} | ||
if (numFound > 1) { | ||
console.warn( | ||
'Deprecation warning: Jasmine found and loaded both jasmine.js ' + | ||
'and jasmine.json\n' + | ||
'config files. In a future version, only the first file found ' + | ||
'will be loaded.' | ||
); | ||
} | ||
} | ||
@@ -216,3 +230,3 @@ } | ||
if(config.requires) { | ||
this.addRequires_(config.requires); | ||
this.addRequires(config.requires); | ||
} | ||
@@ -340,3 +354,3 @@ | ||
addRequires_(requires) { | ||
addRequires(requires) { | ||
const jasmineRunner = this; | ||
@@ -343,0 +357,0 @@ requires.forEach(function(r) { |
@@ -13,3 +13,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.1", | ||
"version": "5.1.0", | ||
"repository": { | ||
@@ -36,3 +36,3 @@ "type": "git", | ||
"glob": "^10.2.2", | ||
"jasmine-core": "~5.0.1" | ||
"jasmine-core": "~5.1.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "bin": "./bin/jasmine.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76327
2104
+ Addedjasmine-core@5.1.2(transitive)
- Removedjasmine-core@5.0.1(transitive)
Updatedjasmine-core@~5.1.0