Skip to content

Commit

Permalink
Fix backward slashes on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Aug 16, 2023
1 parent bd92fd0 commit 6b81bcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion recursive-exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const recursiveExec = {
command: interpolate(command),
};
};
const results = files.map(calcResult);
const results = files.map(slash).map(calcResult);
const execCommand = (result: Result) => {
if (!settings.quiet)
log(logName, chalk.blue.bold('command:'), chalk.cyanBright(result.command));
Expand Down
8 changes: 5 additions & 3 deletions spec/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
import { cliArgvUtil } from 'cli-argv-util';
import assert from 'assert';
import fs from 'fs';
import slash from 'slash';

// Setup
import { recursiveExec } from '../dist/recursive-exec.js';
Expand Down Expand Up @@ -108,10 +109,11 @@ describe('Correct error is thrown', () => {
////////////////////////////////////////////////////////////////////////////////
describe('Executing the CLI', () => {
const run = (posix) => cliArgvUtil.run(pkg, posix);
const readFiles = (folder) => fs.readdirSync(folder, { recursive: true }).map(slash).sort();

it('to compile LESS files to CSS preserves the source folder structure', () => {
run('recursive-exec spec/fixtures/source --ext=.less "lessc {{file}} spec/fixtures/target/css/{{basename}}.css"');
const actual = fs.readdirSync('spec/fixtures/target/css', { recursive: true }).sort();
const actual = readFiles('spec/fixtures/target/css');
const expected = [
'mock1.css',
'subfolder',
Expand All @@ -123,7 +125,7 @@ describe('Executing the CLI', () => {
it('to optimize CSS files preserves the source folder structure', () => {
run('recursive-exec spec/fixtures/source --ext=.js "make-dir spec/fixtures/target/css-min/{{path}}" --quiet');
run('recursive-exec spec/fixtures/target/css "csso {{file}} --output spec/fixtures/target/css-min/{{basename}}.min.css"');
const actual = fs.readdirSync('spec/fixtures/target/css-min', { recursive: true }).sort();
const actual = readFiles('spec/fixtures/target/css-min');
const expected = [
'mock1.min.css',
'subfolder',
Expand All @@ -135,7 +137,7 @@ describe('Executing the CLI', () => {
it('to minimize JS files preserves the source folder structure', () => {
run('recursive-exec spec/fixtures/source --ext=.js --quiet "make-dir spec/fixtures/target/js/{{path}}"');
run('recursive-exec spec/fixtures/source --ext=.js "uglifyjs {{file}} --output spec/fixtures/target/js/{{basename}}.min.js"');
const actual = fs.readdirSync('spec/fixtures/target/js', { recursive: true }).sort();
const actual = readFiles('spec/fixtures/target/js');
const expected = [
'mock1.min.js',
'subfolder',
Expand Down

0 comments on commit 6b81bcc

Please sign in to comment.