Skip to content

Commit 2edaebb

Browse files
committed
test: try avoiding slashes to work in windows
1 parent cc18341 commit 2edaebb

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { readFileSync } from 'fs';
55
import { join } from 'path';
66
import { perform } from './perform';
77

8-
const PACKAGE_PATH = join(__dirname, '../package.json');
8+
const PACKAGE_PATH = join(__dirname, '..', 'package.json');
99
const PACKAGE_JSON = JSON.parse(readFileSync(PACKAGE_PATH, 'utf8'));
1010
const NAME = PACKAGE_JSON.name;
1111
const VERSION = PACKAGE_JSON.version;

test/cli.test.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,36 @@ import glob from 'glob';
33
import path from 'path';
44
import fs from 'fs-extra';
55

6-
const bin = './dist/cli.js';
6+
const bin = path.join(__dirname, '..', 'dist', 'cli.js');
77
const cache = path.join(__dirname, '.cache');
88

99
const run = (recipe: string) => {
1010
// Setup the test files
11-
const originalInput = `./recipes/${recipe}/input`;
11+
const originalInput = path.join(__dirname, '..', 'recipes', recipe, 'input');
1212
const inputDest = path.resolve(cache, recipe);
1313
fs.copySync(originalInput, inputDest);
1414

1515
// Run the command
16-
const transform = `./recipes/${recipe}/transform.ts`;
17-
const inputGlob = `${inputDest}/**/*.css`;
16+
const transform = path.join(
17+
__dirname,
18+
'..',
19+
'recipes',
20+
recipe,
21+
'transform.ts'
22+
);
23+
const inputGlob = path.join(inputDest, '**', '*.css');
1824
const command = `${bin} -t ${transform} '${inputGlob}'`;
1925
execSync(command);
2026

2127
// Compare results
22-
const expectedOutput = `./recipes/${recipe}/output`;
23-
const expectedOutputGlob = `${expectedOutput}/**/*.css`;
28+
const expectedOutput = path.join(
29+
__dirname,
30+
'..',
31+
'recipes',
32+
recipe,
33+
'output'
34+
);
35+
const expectedOutputGlob = path.join(expectedOutput, '**', '*.css');
2436
const expectedFiles = glob.sync(expectedOutputGlob);
2537

2638
expectedFiles.forEach(expectedFile => {
@@ -32,7 +44,7 @@ const run = (recipe: string) => {
3244
});
3345
};
3446

35-
const recipes = fs.readdirSync(path.resolve(__dirname, '../recipes'));
47+
const recipes = fs.readdirSync(path.resolve(__dirname, '..', 'recipes'));
3648

3749
describe('cli', () => {
3850
beforeAll(() => {

0 commit comments

Comments
 (0)