-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from iambumblehead/re-30-handle-windows-style-…
…module-paths handle windows style module path
- Loading branch information
Showing
4 changed files
with
49 additions
and
4 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "resolvewithplus", | ||
"version": "0.8.7", | ||
"version": "0.8.8", | ||
"engines" : { | ||
"node" : ">=12.16.0" | ||
}, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,46 @@ | |
// Timestamp: 2017.04.23-23:31:33 (last modified) | ||
// Author(s): bumblehead <[email protected]> | ||
|
||
import url from 'url'; | ||
import url, { fileURLToPath } from 'url'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import test from 'node:test' | ||
import assert from 'node:assert/strict' | ||
import resolvewithplus from '../../resolvewithplus.js'; | ||
|
||
test('should convert win32 path to node-friendly posix path', () => { | ||
const win32Path = 'D:\\a\\resolvewithplus\\pathto\\testfiles\\testscript.js'; | ||
const posixPath = '/a/resolvewithplus/pathto/testfiles/testscript.js'; | ||
const returnPath = resolvewithplus.pathToPosix(win32Path); | ||
|
||
assert.strictEqual(returnPath, posixPath); | ||
}) | ||
|
||
test('should pass windows and posix system-specific module path', () => { | ||
const modulePath = fileURLToPath( | ||
new URL('../testfiles/testscript.js', import.meta.url)) | ||
const calleePath = import.meta.url; | ||
const returnPath = resolvewithplus(modulePath, calleePath) | ||
// posix modulePath | ||
// /root/pathto/testfiles/testscript.js | ||
// posix calleePath | ||
// file:///root/pathto/tests-basic/tests-basic.test.js | ||
// posix returnPath | ||
// /root/pathto/testfiles/testscript.js | ||
// | ||
// win32 modulePath | ||
// D:\\a\\resolvewithplus\\pathto\\testfiles\\testscript.js | ||
// win32 calleePath eslint-disable-next-line max-len | ||
// file:///D:/a/resolvewithplus/pathto/tests-basic/tests-basic.test.js | ||
// returnPath | ||
// D:\\a\\resolvewithplus\\pathto\\testfiles\\testscript.js | ||
assert.ok(typeof returnPath === 'string') | ||
assert.ok(returnPath.endsWith( | ||
os.platform() === 'win32' | ||
? '\\tests\\testfiles\\testscript.js' | ||
: '/tests/testfiles/testscript.js')) | ||
}); | ||
|
||
test('should return a core module reference as require.resolve id', () => { | ||
assert.strictEqual(resolvewithplus('path'), 'path'); | ||
}); | ||
|