44 */
55'use strict' ;
66
7- const { resolve} = require ( 'path' ) ;
7+ const { resolve, sep} = require ( 'path' ) ;
8+ const { platform} = require ( 'os' ) ;
89const tape = require ( 'blue-tape' ) ;
910const sinon = require ( 'sinon' ) ;
1011const outdent = require ( 'outdent' ) ;
@@ -17,6 +18,15 @@ const json = (strings, ...substitutions) =>
1718 ...substitutions . map ( v => JSON . stringify ( v , ( _ , vv ) => Number . isNaN ( vv ) ? 'NaN' : vv ) )
1819 ) ;
1920
21+ const cwd = ( ...args ) =>
22+ resolve ( ...String . raw ( ...args ) . split ( '/' ) ) ;
23+
24+ const root = ( ...args ) =>
25+ resolve (
26+ platform ( ) === 'win32' ? ( process . cwd ( ) . split ( sep ) . shift ( ) + sep ) : sep ,
27+ ...String . raw ( ...args ) . split ( '/' )
28+ ) ;
29+
2030tape (
2131 'debug' ,
2232 ( { name, test, end : end1 , equal, looseEqual} ) => {
@@ -25,16 +35,16 @@ tape(
2535 // absolute within cwd
2636 [
2737 [
28- resolve ( ' my-source-file.js' ) ,
38+ cwd ` my-source-file.js` ,
2939 'my-asset.png' ,
3040 [
3141 {
32- base : resolve ( ' foo' ) ,
33- joined : resolve ( ' foo' , ' my-asset.png' ) ,
42+ base : cwd ` foo` ,
43+ joined : cwd ` foo/ my-asset.png` ,
3444 isSuccess : false
3545 } , {
36- base : resolve ( ' bar' , ' baz' ) ,
37- joined : resolve ( ' bar' , ' baz' , ' my-asset.png' ) ,
46+ base : cwd ` bar/ baz` ,
47+ joined : cwd ` bar/ baz/ my-asset.png` ,
3848 isSuccess : true
3949 }
4050 ]
@@ -49,24 +59,24 @@ tape(
4959 // absolute otherwise
5060 [
5161 [
52- '/ my-source-file.js' ,
53- '#anything\\ ./goes' ,
62+ root ` my-source-file.js` ,
63+ '#anything@ ./goes' ,
5464 [
5565 {
56- base : '/ foo' ,
57- joined : '/ foo/#anything\\ ./goes' ,
66+ base : root ` foo` ,
67+ joined : root ` foo/#anything@ ./goes` ,
5868 isSuccess : false
5969 } , {
60- base : '/ bar/baz' ,
61- joined : '/ bar/baz/#anything\\ ./goes' ,
70+ base : root ` bar/baz` ,
71+ joined : root ` bar/baz/#anything@ ./goes` ,
6272 isSuccess : false
6373 }
6474 ]
6575 ] ,
6676 outdent `
67- resolve-url-loader: /my-source-file.js: #anything\\ ./goes
68- /foo --> /foo/#anything\\ ./goes
69- /bar/baz --> /bar/baz/#anything\\ ./goes
77+ resolve-url-loader: /my-source-file.js: #anything@ ./goes
78+ /foo --> /foo/#anything@ ./goes
79+ /bar/baz --> /bar/baz/#anything@ ./goes
7080 NOT FOUND
7181 `
7282 ] ,
0 commit comments