Skip to content

Commit 7691135

Browse files
author
Ivan Demidov
committed
Fixed test for windows
1 parent 0abb7ff commit 7691135

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

cli.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ var argv = require('yargs')
99
.usage('Usage: $0 [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config]')
1010
.example('posthtml -o output.html -i input.html', 'Default example')
1111
.alias('i', 'input')
12+
.array('input')
13+
.demand(['i'])
1214
.alias('o', 'output')
1315
.alias('r', 'replace')
1416
.alias('u', 'use')
1517
.array('use')
16-
.describe('u', 'posthtml plugin name (can be used multiple times)')
17-
.demand(['i'])
18-
.array('input')
1918
.pkgConf('posthtml')
2019
.config('c')
2120
.alias('c', 'config')

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"posthtml-bem": "^0.2.2",
4646
"posthtml-custom-elements": "^1.0.3",
4747
"read-pkg": "^1.1.0",
48+
"temp-write": "^2.1.0",
4849
"tempfile": "^1.1.1",
4950
"updtr": "^0.1.10",
5051
"xo": "^0.15.0"

test/test-cli.js

+11-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const execa = require('execa');
55
const pathExists = require('path-exists');
66
const readPkg = require('read-pkg');
77
const copy = require('cpy');
8+
const tempwrite = require('temp-write');
89
const tempfile = require('tempfile');
910

1011
function read(pathFile) {
@@ -18,7 +19,7 @@ function read(pathFile) {
1819
});
1920
}
2021

21-
test('Missing required arguments -i, -o, -u', t => {
22+
test('Missing required arguments -i, -o', t => {
2223
t.throws(execa('../cli.js', []));
2324
});
2425

@@ -27,17 +28,12 @@ test('Missing required arguments -o', t => {
2728
});
2829

2930
test('Missing required arguments -i', t => {
30-
const filename = tempfile('.html');
31-
t.throws(execa('../cli.js', [`-o ${filename}`]));
32-
});
33-
34-
test('Missing required arguments -u', t => {
35-
const filename = tempfile('.html');
36-
t.throws(execa('../cli.js', [`-o ${filename} -i fixtures/input.html`]));
31+
const filename = tempwrite.sync('output.html');
32+
t.throws(execa('../cli.js', ['-o', filename]));
3733
});
3834

3935
test('One of the arguments', t => {
40-
const filename = tempfile('.html');
36+
const filename = tempwrite.sync('output.html');
4137
t.throws(execa('../cli.js', ['-o', filename, '-r', '-i', 'fixtures/input.html']));
4238
});
4339

@@ -47,39 +43,39 @@ test('Check version', async t => {
4743

4844
test('Transform html witch config in package.json', async t => {
4945
t.plan(2);
50-
const filename = tempfile('.html');
46+
const filename = await tempwrite('', 'output.html');
5147
await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename]);
5248
t.true(await pathExists(filename));
5349
t.is((await read('expected/output-config-pkg.html')), (await read(filename)));
5450
});
5551

5652
test('Transform html witch indent', async t => {
5753
t.plan(2);
58-
const filename = tempfile('.html');
54+
const filename = await tempwrite('', 'output.html');
5955
await execa('../cli.js', ['-i', 'fixtures/input-indent.html', '-o', filename]);
6056
t.true(await pathExists(filename));
6157
t.is((await read('expected/output-indent.html')), (await read(filename)));
6258
});
6359

6460
test('Transform html witch config in file', async t => {
6561
t.plan(2);
66-
const filename = tempfile('.html');
62+
const filename = await tempwrite('', 'output.html');
6763
await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']);
6864
t.true(await pathExists(filename));
6965
t.is((await read('expected/output-config-file.html')), (await read(filename)));
7066
});
7167

7268
test('Transform html from folder', async t => {
7369
t.plan(2);
74-
const folder = tempfile();
70+
const folder = await tempfile();
7571
await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]);
7672
t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`)));
7773
t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`)));
7874
});
7975

8076
test('Transform html witch options replace', async t => {
8177
t.plan(2);
82-
const folder = tempfile();
78+
const folder = await tempfile();
8379
await copy(['fixtures/*.html'], `${folder}/`);
8480
await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']);
8581
t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`)));
@@ -88,7 +84,7 @@ test('Transform html witch options replace', async t => {
8884

8985
test('Transform html witch config in file and stdin options use', async t => {
9086
t.plan(2);
91-
const filename = tempfile('.html');
87+
const filename = await tempwrite('', 'output.html');
9288
await execa('../cli.js', [
9389
'-o',
9490
filename,

0 commit comments

Comments
 (0)