Skip to content

Commit

Permalink
chore: test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
iChenLei committed Sep 8, 2023
1 parent 67a99ad commit 7315d5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/less/test/browser/generator/runner.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
var path = require('path');
var resolve = require('resolve')
var resolve = require('resolve');
var { forceCovertToBrowserPath } = require('./utils');

/** Root of repo */
var testFolder = path.posix.normalize(path.dirname(resolve.sync('@less/test-data')));
var lessFolder = path.posix.normalize(path.join(testFolder, 'less'));
var localTests = path.posix.normalize(path.resolve(__dirname, '..'));
var testFolder = forceCovertToBrowserPath(path.dirname(resolve.sync('@less/test-data')));
var lessFolder = forceCovertToBrowserPath(path.join(testFolder, 'less'));
var localTests = forceCovertToBrowserPath(path.resolve(__dirname, '..'));

console.log(
`normalize: `, path.normalize(path.dirname(resolve.sync('@less/test-data'))),
`posix normalize: `, path.posix.normalize(path.dirname(resolve.sync('@less/test-data')))
`normal: `, path.dirname(resolve.sync('@less/test-data')),
`forceCovertToBrowserPath: `, forceCovertToBrowserPath(path.dirname(resolve.sync('@less/test-data')))
)

module.exports = {
Expand Down
14 changes: 14 additions & 0 deletions packages/less/test/browser/generator/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* utils for covert browser paths,
* fix https://github.com/less/less.js/pull/4213
*
* @param {string} path
* @returns {string}
*/
function forceCovertToBrowserPath (path) {
return (path || '').replace(/\\/g, '/');
}

module.exports = {
forceCovertToBrowserPath
}

0 comments on commit 7315d5e

Please sign in to comment.