Skip to content

Commit

Permalink
Convert path to URL before import of config/plugin for Windows support (
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Apr 28, 2023
1 parent 2b1ad76 commit a5a3a42
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function resolveProjectConfig(workingDir, options) {
options.resolvedConfigPath = configPath;

try {
const { default: config } = await import(configPath);
const { default: config } = await import(pathToFileURL(configPath));
return config;
} catch (error) {
// Fallback to ensure we can load CJS configs in Node versions before 16 (TODO: remove eventually).
Expand Down
31 changes: 31 additions & 0 deletions test/acceptance/cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,37 @@ describe('ember-template-lint executable', function () {
});
});

describe('multiplatform config resolve', function () {
describe('given absolute config path and path to single file without errors', function () {
it('should exit without error and any console output', async function () {
await project.setConfig({
rules: {
'no-bare-strings': false,
},
});
await project.write({
app: {
templates: {
'application.hbs':
'<h2>Love for bare strings!!!</h2> <div>Bare strings are great!</div>',
},
},
});

let configPath = path.join(project.baseDir, '.template-lintrc.js');

expect(path.isAbsolute(configPath)).toBeTruthy();
expect(fs.existsSync(configPath)).toBeTruthy();

let result = await runBin('app/templates/application.hbs', '--config-path', configPath);

expect(result.exitCode).toEqual(0);
expect(result.stdout).toBeFalsy();
expect(result.stderr).toBeFalsy();
});
});
});

describe('reading from stdin', function () {
describe('given no path', function () {
setupEnvVar('CI', null);
Expand Down

0 comments on commit a5a3a42

Please sign in to comment.