Skip to content

Commit a6afb33

Browse files
author
Ivan Demidov
committed
Fixed #79, test for windows
1 parent 7691135 commit a6afb33

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
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",
4948
"tempfile": "^1.1.1",
5049
"updtr": "^0.1.10",
5150
"xo": "^0.15.0"

test/test-cli.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ 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');
98
const tempfile = require('tempfile');
9+
const cli = path.resolve('../cli.js');
1010

1111
function read(pathFile) {
1212
return new Promise((resolve, reject) => {
@@ -20,55 +20,55 @@ function read(pathFile) {
2020
}
2121

2222
test('Missing required arguments -i, -o', t => {
23-
t.throws(execa('../cli.js', []));
23+
t.throws(execa(cli, []));
2424
});
2525

2626
test('Missing required arguments -o', t => {
27-
t.throws(execa('../cli.js', ['-i', 'fixtures/input.html']));
27+
t.throws(execa(cli, ['-i', 'fixtures/input.html']));
2828
});
2929

3030
test('Missing required arguments -i', t => {
31-
const filename = tempwrite.sync('output.html');
32-
t.throws(execa('../cli.js', ['-o', filename]));
31+
const filename = tempfile('.html');
32+
t.throws(execa(cli, ['-o', filename]));
3333
});
3434

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

4040
test('Check version', async t => {
41-
t.is((await execa('../cli.js', ['-v'])).stdout, (await readPkg(path.dirname(__dirname))).version);
41+
t.is((await execa(cli, ['-v'])).stdout, (await readPkg(path.dirname(__dirname))).version);
4242
});
4343

4444
test('Transform html witch config in package.json', async t => {
4545
t.plan(2);
46-
const filename = await tempwrite('', 'output.html');
47-
await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename]);
46+
const filename = tempfile('.html');
47+
await execa(cli, ['-i', 'fixtures/input.html', '-o', filename]);
4848
t.true(await pathExists(filename));
4949
t.is((await read('expected/output-config-pkg.html')), (await read(filename)));
5050
});
5151

5252
test('Transform html witch indent', async t => {
5353
t.plan(2);
54-
const filename = await tempwrite('', 'output.html');
55-
await execa('../cli.js', ['-i', 'fixtures/input-indent.html', '-o', filename]);
54+
const filename = tempfile('.html');
55+
await execa(cli, ['-i', 'fixtures/input-indent.html', '-o', filename]);
5656
t.true(await pathExists(filename));
5757
t.is((await read('expected/output-indent.html')), (await read(filename)));
5858
});
5959

6060
test('Transform html witch config in file', async t => {
6161
t.plan(2);
62-
const filename = await tempwrite('', 'output.html');
63-
await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']);
62+
const filename = tempfile('.html');
63+
await execa(cli, ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']);
6464
t.true(await pathExists(filename));
6565
t.is((await read('expected/output-config-file.html')), (await read(filename)));
6666
});
6767

6868
test('Transform html from folder', async t => {
6969
t.plan(2);
7070
const folder = await tempfile();
71-
await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]);
71+
await execa(cli, ['-i', 'fixtures/*.html', '-o', `${folder}/`]);
7272
t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`)));
7373
t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`)));
7474
});
@@ -77,15 +77,15 @@ test('Transform html witch options replace', async t => {
7777
t.plan(2);
7878
const folder = await tempfile();
7979
await copy(['fixtures/*.html'], `${folder}/`);
80-
await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']);
80+
await execa(cli, ['-i', `${folder}/*.html`, '-r']);
8181
t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`)));
8282
t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`)));
8383
});
8484

8585
test('Transform html witch config in file and stdin options use', async t => {
8686
t.plan(2);
87-
const filename = await tempwrite('', 'output.html');
88-
await execa('../cli.js', [
87+
const filename = tempfile('.html');
88+
await execa(cli, [
8989
'-o',
9090
filename,
9191
'-i',

0 commit comments

Comments
 (0)