Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit b0cfa00

Browse files
committed
fix(cli): allow specify test runner
1 parent deaf011 commit b0cfa00

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/cli.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,27 @@ const compile = async (
244244
return result;
245245
};
246246

247+
/**
248+
* NOTE: What is this hack even?
249+
* for sass-spec it validates output of message which includes input file's path, which libsass-asm
250+
* doesn't uses but internally wires to virtual mounted path. This leads into test failure -
251+
* for those in test runner, strip out mounted path to allow spec runner validates test output.
252+
*/
253+
const overrideStdErr = ({ mountedFullPath, raw }: { mountedFullPath: string; raw: string }) => {
254+
if (!process.env.SASS_SPEC) {
255+
return;
256+
}
257+
258+
d(`overrideStdErr: specified as test runner, strip out mounted path from console output`);
259+
260+
const root = mountedFullPath.slice(0, mountedFullPath.indexOf(path.resolve(raw)));
261+
const original = process.stderr.write.bind(process.stderr);
262+
process.stderr.write = function(arg: string) {
263+
const replaced = arg.replace(root, '');
264+
return original(replaced);
265+
};
266+
};
267+
247268
const main = async (argv: Array<string> = process.argv) => {
248269
const options = commandLineArgs(optionDefinitions, { argv, camelCase: true });
249270
const displayHelp = options.help || Object.keys(options).length === 0;
@@ -279,6 +300,8 @@ const main = async (argv: Array<string> = process.argv) => {
279300
};
280301
});
281302

303+
overrideStdErr(mountedInput);
304+
282305
const sassOption = buildSassOption(context, options, !!mountedOutput ? mountedOutput.mountedFullPath : undefined);
283306

284307
const result = options.stdin

0 commit comments

Comments
 (0)