From a39a866ed963c64cda2179e77f432d0e7ea5aad1 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Wed, 4 May 2016 12:28:03 +0300 Subject: [PATCH 01/16] Fixed #73, update devDep --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c70ded6..37cf4ed 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,13 @@ "cpy": "^4.0.0", "execa": "^0.4.0", "nyc": "^6.4.1", - "path-exists": "^2.1.0", + "path-exists": "^3.0.0", "posthtml-custom-elements": "^1.0.3", "read-pkg": "^1.1.0", "temp-write": "^2.1.0", "tempfile": "^1.1.1", "updtr": "^0.1.10", - "xo": "^0.13.0" + "xo": "^0.15.0" }, "posthtml": { "posthtmlCustomElements": {} From cf36ba5b6c60a0c4122c6360b92039de8a9a3338 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Wed, 4 May 2016 12:29:52 +0300 Subject: [PATCH 02/16] Fixed linter report error --- cli.js | 6 +++--- test/test-cli.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli.js b/cli.js index 6c66342..f085522 100755 --- a/cli.js +++ b/cli.js @@ -1,10 +1,10 @@ #!/usr/bin/env node -var posthtml = require('posthtml'); -var globby = require('globby'); var path = require('path'); -const pathExists = require('path-exists'); var fs = require('fs'); +var posthtml = require('posthtml'); +var globby = require('globby'); +var pathExists = require('path-exists'); var argv = require('yargs') .usage('Usage: $0 --output|-o output.html/outputFolder --input|-i input.html/inputFolder [--config|-c config.(js|json)] [--replace|-r]') .example('posthtml -o output.html -i input.html', 'Default example') diff --git a/test/test-cli.js b/test/test-cli.js index 0b0abfb..f56a9a5 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -1,11 +1,11 @@ +const path = require('path'); +const readFile = require('fs').readFile; const test = require('ava'); const execa = require('execa'); const tempWrite = require('temp-write'); const pathExists = require('path-exists'); -const path = require('path'); const readPkg = require('read-pkg'); const copy = require('cpy'); -const readFile = require('fs').readFile; const tempfile = require('tempfile'); function read(pathFile) { From 0cd9b484cc6cdc896f4f3d635485e6b6d2b5bd3c Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Wed, 4 May 2016 17:33:19 +0300 Subject: [PATCH 03/16] Update config posthtml for test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 37cf4ed..6c49a4a 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,6 @@ "xo": "^0.15.0" }, "posthtml": { - "posthtmlCustomElements": {} + "customElements": {} } } From f53eeb41edcc0aeba1443118b96307b79b51b1be Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Wed, 4 May 2016 17:37:29 +0300 Subject: [PATCH 04/16] Fixed #73, update devDep --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6c49a4a..cb28ebd 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "homepage": "https://github.com/GitScrum/posthtml-cli#readme", "dependencies": { "globby": "^4.0.0", - "posthtml": "^0.8.6", - "posthtml-load-plugins": "^0.9.5", + "posthtml": "^0.8.7", + "posthtml-load-plugins": "^0.10.0", "yargs": "^4.6.0" }, "devDependencies": { From 3a65613cdceb4d76e832824bd10e8db934312dec Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:21:42 +0300 Subject: [PATCH 05/16] Fixed #75, update readme --- README.md | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 002f1a8..2a24ac7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ npm install --global posthtml-cli $ posthtml --help Usage - posthtml --output|-o output.html --input|-i input.html [--config|-c path/to/json/config] + posthtml [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config] [--use|-u plugin] Options --config, -c Path to JSON file [string] @@ -62,7 +62,8 @@ $ posthtml --help ### ```[name].[ext]``` -#### JS +#### ```JS``` + ```js module.exports = { bem: { @@ -79,6 +80,7 @@ module.exports = { } } ``` + #### ```JSON``` ```json @@ -100,12 +102,12 @@ module.exports = { ## Examples -### Example sample +### Sample ```console $ posthtml -o output.html -i input.html ``` -### Example options config +### Options config ```console $ posthtml -o output.html -i input.html -c posthtml.json ``` @@ -114,7 +116,19 @@ $ posthtml -o output.html -i input.html -c posthtml.json $ posthtml -o output.html -i input.html -c posthtml.js ``` -### Example read dir +### Options use +```console +$ posthtml + -o output.html + -i input.html + -c config.json + -u posthtml-bem + --posthtml-bem.elemPrefix __ + --posthtml-bem.elemMod _ + -u posthtml-custom-elements +``` + +### Read dir ```console $ posthtml -o outputFolder/ -i inputFolder/*.html ``` @@ -123,6 +137,15 @@ $ posthtml -o outputFolder/ -i inputFolder/*.html $ posthtml -o outputFolder/ -i inputFolder/**/*.html ``` +### Replace +```console +$ posthtml -i input.html -r +``` + +```console +$ posthtml -i inputFolder/*.html -r +``` + ## License MIT From 89732b5bc9f982201173122f98edf244e027a00c Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:23:35 +0300 Subject: [PATCH 06/16] Fixed #72, add option use --- cli.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cli.js b/cli.js index f085522..5021b59 100755 --- a/cli.js +++ b/cli.js @@ -6,11 +6,14 @@ var posthtml = require('posthtml'); var globby = require('globby'); var pathExists = require('path-exists'); var argv = require('yargs') - .usage('Usage: $0 --output|-o output.html/outputFolder --input|-i input.html/inputFolder [--config|-c config.(js|json)] [--replace|-r]') + .usage('Usage: $0 [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config]') .example('posthtml -o output.html -i input.html', 'Default example') .alias('i', 'input') .alias('o', 'output') .alias('r', 'replace') + .alias('u', 'use') + .array('use') + .describe('u', 'posthtml plugin name (can be used multiple times)') .demand(['i']) .array('input') .pkgConf('posthtml') @@ -36,9 +39,17 @@ var argv = require('yargs') function processing(file, output) { // get htmls var html = fs.readFileSync(file, 'utf8'); + var ext = {}; + + // create config extends for posthtml-load-plugins + if (argv.use) { + argv.use.forEach(function (plugin) { + ext[plugin] = argv[plugin] || {}; + }); + } // processing - posthtml(require('posthtml-load-plugins')(argv.config)) + posthtml(require('posthtml-load-plugins')(argv.config, ext)) .process(html) .then(function (result) { fs.writeFileSync(output, result.html); @@ -73,6 +84,7 @@ globby(argv.input).then(function (files) { if (argv.output !== undefined) { createFolder(argv.output); } + files.forEach(function (file) { var output = isFile(argv.output) ? argv.output : getOutput(file); processing(file, output); From ffacaa98772c7edd6632e71235d0efcc0cad5948 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:23:56 +0300 Subject: [PATCH 07/16] Update tests for option use --- test/expected/output-bem.html | 4 +++ test/fixtures/config-for-bem.json | 10 +++++++ test/fixtures/input-bem.html | 4 +++ test/test-cli.js | 49 ++++++++++++++++++++++++------- 4 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 test/expected/output-bem.html create mode 100644 test/fixtures/config-for-bem.json create mode 100644 test/fixtures/input-bem.html diff --git a/test/expected/output-bem.html b/test/expected/output-bem.html new file mode 100644 index 0000000..b6fdd6e --- /dev/null +++ b/test/expected/output-bem.html @@ -0,0 +1,4 @@ +
+
Super Title
+
Awesome Text
+
diff --git a/test/fixtures/config-for-bem.json b/test/fixtures/config-for-bem.json new file mode 100644 index 0000000..2a627ec --- /dev/null +++ b/test/fixtures/config-for-bem.json @@ -0,0 +1,10 @@ +{ + "bem": { + "elemPrefix": "__", + "modPrefix": "-", + "modDlmtr": "--" + }, + "customElements": { + "defaultTag": "span" + } +} diff --git a/test/fixtures/input-bem.html b/test/fixtures/input-bem.html new file mode 100644 index 0000000..d00be0d --- /dev/null +++ b/test/fixtures/input-bem.html @@ -0,0 +1,4 @@ + + Super Title + Awesome Text + diff --git a/test/test-cli.js b/test/test-cli.js index f56a9a5..f6d80df 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -1,8 +1,7 @@ const path = require('path'); -const readFile = require('fs').readFile; +const fs = require('fs'); const test = require('ava'); const execa = require('execa'); -const tempWrite = require('temp-write'); const pathExists = require('path-exists'); const readPkg = require('read-pkg'); const copy = require('cpy'); @@ -10,7 +9,7 @@ const tempfile = require('tempfile'); function read(pathFile) { return new Promise((resolve, reject) => { - readFile(pathFile, 'utf8', (err, data) => { + fs.readFile(pathFile, 'utf8', (err, data) => { if (err) { reject(err); } @@ -19,7 +18,7 @@ function read(pathFile) { }); } -test('Missing required arguments -i, -o', t => { +test('Missing required arguments -i, -o, -u', t => { t.throws(execa('../cli.js', [])); }); @@ -28,12 +27,17 @@ test('Missing required arguments -o', t => { }); test('Missing required arguments -i', t => { - const filename = tempWrite.sync('output.html'); + const filename = tempfile('.html'); t.throws(execa('../cli.js', [`-o ${filename}`])); }); +test('Missing required arguments -u', t => { + const filename = tempfile('.html'); + t.throws(execa('../cli.js', [`-o ${filename} -i fixtures/input.html`])); +}); + test('One of the arguments', t => { - const filename = tempWrite.sync('output.html'); + const filename = tempfile('.html'); t.throws(execa('../cli.js', ['-o', filename, '-r', '-i', 'fixtures/input.html'])); }); @@ -43,7 +47,7 @@ test('Check version', async t => { test('Transform html witch config in package.json', async t => { t.plan(2); - const filename = await tempWrite('output.html', 'output.html'); + const filename = tempfile('.html'); await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename]); t.true(await pathExists(filename)); t.is((await read('expected/output-config-pkg.html')), (await read(filename))); @@ -51,7 +55,7 @@ test('Transform html witch config in package.json', async t => { test('Transform html witch indent', async t => { t.plan(2); - const filename = await tempWrite('output.html', 'output.html'); + const filename = tempfile('.html'); await execa('../cli.js', ['-i', 'fixtures/input-indent.html', '-o', filename]); t.true(await pathExists(filename)); t.is((await read('expected/output-indent.html')), (await read(filename))); @@ -59,7 +63,7 @@ test('Transform html witch indent', async t => { test('Transform html witch config in file', async t => { t.plan(2); - const filename = await tempWrite('output.html', 'output.html'); + const filename = tempfile('.html'); await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']); t.true(await pathExists(filename)); t.is((await read('expected/output-config-file.html')), (await read(filename))); @@ -67,7 +71,7 @@ test('Transform html witch config in file', async t => { test('Transform html from folder', async t => { t.plan(2); - const folder = await tempfile(); + const folder = tempfile(); await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`))); @@ -75,9 +79,32 @@ test('Transform html from folder', async t => { test('Transform html witch options replace', async t => { t.plan(2); - const folder = await tempfile(); + const folder = tempfile(); await copy(['fixtures/*.html'], `${folder}/`); await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`))); }); + +test('Transform html witch config in file and stdin options use', async t => { + t.plan(2); + const filename = tempfile('.html'); + await execa('../cli.js', [ + '-o', + filename, + '-i', + 'fixtures/input-bem.html', + '-c', + 'fixtures/config.json', + '-u', + 'posthtml-bem', + '--posthtml-bem.elemPrefix', + '__', + '--posthtml-bem.elemMod', + '_', + '-u', + 'posthtml-custom-elements' + ]); + t.true(await pathExists(filename)); + t.is((await read('expected/output-bem.html')), (await read(filename))); +}); From 72b5c3462ce953500021b6a15c2bc7ee82675bac Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:24:08 +0300 Subject: [PATCH 08/16] bump --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75092fb..b4924a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## [0.2.0] - 05-05-2016 +### Added +- Added #72, options --use + +### Change +- Update #73, devDep +- Update config posthtml in package.json for test +- Update #75, readme +- Update tests for options --use + +### Fixed +- Fixed linter report error + ## [0.1.2] - 28-04-2016 ### Added - Added #68, node 6 to config travis From 9189a5dcdbf17f853fc8613de4ba73d2979b61f4 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:25:53 +0300 Subject: [PATCH 09/16] Remove temp-write, now used tempfile --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index cb28ebd..c0e0cb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthtml-cli", - "version": "0.1.2", + "version": "0.2.0", "description": "CLI for posthtml", "bin": { "posthtml": "./cli.js" @@ -44,7 +44,6 @@ "path-exists": "^3.0.0", "posthtml-custom-elements": "^1.0.3", "read-pkg": "^1.1.0", - "temp-write": "^2.1.0", "tempfile": "^1.1.1", "updtr": "^0.1.10", "xo": "^0.15.0" From 923d93df561ecf03f7016c5dda7e4a5addd5f322 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:26:10 +0300 Subject: [PATCH 10/16] bump --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4924a3..1d91ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ ### Fixed - Fixed linter report error +## Removed +- Remove temp-write now used tempfile + ## [0.1.2] - 28-04-2016 ### Added - Added #68, node 6 to config travis From 4f70a339099b0e5d4021e2f9c128f368213457f8 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:27:07 +0300 Subject: [PATCH 11/16] Revert version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0e0cb4..aef788a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthtml-cli", - "version": "0.2.0", + "version": "0.1.2", "description": "CLI for posthtml", "bin": { "posthtml": "./cli.js" From 393f592b2e47a5281ad756811b0fd7a26f4b3cf9 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 11:27:28 +0300 Subject: [PATCH 12/16] v0.1.2 ... v0.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aef788a..c0e0cb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthtml-cli", - "version": "0.1.2", + "version": "0.2.0", "description": "CLI for posthtml", "bin": { "posthtml": "./cli.js" From 0abb7ffe0f5adb4b2d1c00057d7e952c4f258958 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 12:19:50 +0300 Subject: [PATCH 13/16] Add posthtml-bem for testing --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c0e0cb4..8aba9c6 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "execa": "^0.4.0", "nyc": "^6.4.1", "path-exists": "^3.0.0", + "posthtml-bem": "^0.2.2", "posthtml-custom-elements": "^1.0.3", "read-pkg": "^1.1.0", "tempfile": "^1.1.1", From 769113590ba82daa8c22c19120a553b150c94560 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 12:40:28 +0300 Subject: [PATCH 14/16] Fixed test for windows --- cli.js | 5 ++--- package.json | 1 + test/test-cli.js | 26 +++++++++++--------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/cli.js b/cli.js index 5021b59..ee419b5 100755 --- a/cli.js +++ b/cli.js @@ -9,13 +9,12 @@ var argv = require('yargs') .usage('Usage: $0 [-o output-file/directory|-r] [-i input-file/directory] [--config|-c path/to/file/config]') .example('posthtml -o output.html -i input.html', 'Default example') .alias('i', 'input') + .array('input') + .demand(['i']) .alias('o', 'output') .alias('r', 'replace') .alias('u', 'use') .array('use') - .describe('u', 'posthtml plugin name (can be used multiple times)') - .demand(['i']) - .array('input') .pkgConf('posthtml') .config('c') .alias('c', 'config') diff --git a/package.json b/package.json index 8aba9c6..a09c809 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "posthtml-bem": "^0.2.2", "posthtml-custom-elements": "^1.0.3", "read-pkg": "^1.1.0", + "temp-write": "^2.1.0", "tempfile": "^1.1.1", "updtr": "^0.1.10", "xo": "^0.15.0" diff --git a/test/test-cli.js b/test/test-cli.js index f6d80df..7262012 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -5,6 +5,7 @@ const execa = require('execa'); const pathExists = require('path-exists'); const readPkg = require('read-pkg'); const copy = require('cpy'); +const tempwrite = require('temp-write'); const tempfile = require('tempfile'); function read(pathFile) { @@ -18,7 +19,7 @@ function read(pathFile) { }); } -test('Missing required arguments -i, -o, -u', t => { +test('Missing required arguments -i, -o', t => { t.throws(execa('../cli.js', [])); }); @@ -27,17 +28,12 @@ test('Missing required arguments -o', t => { }); test('Missing required arguments -i', t => { - const filename = tempfile('.html'); - t.throws(execa('../cli.js', [`-o ${filename}`])); -}); - -test('Missing required arguments -u', t => { - const filename = tempfile('.html'); - t.throws(execa('../cli.js', [`-o ${filename} -i fixtures/input.html`])); + const filename = tempwrite.sync('output.html'); + t.throws(execa('../cli.js', ['-o', filename])); }); test('One of the arguments', t => { - const filename = tempfile('.html'); + const filename = tempwrite.sync('output.html'); t.throws(execa('../cli.js', ['-o', filename, '-r', '-i', 'fixtures/input.html'])); }); @@ -47,7 +43,7 @@ test('Check version', async t => { test('Transform html witch config in package.json', async t => { t.plan(2); - const filename = tempfile('.html'); + const filename = await tempwrite('', 'output.html'); await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename]); t.true(await pathExists(filename)); t.is((await read('expected/output-config-pkg.html')), (await read(filename))); @@ -55,7 +51,7 @@ test('Transform html witch config in package.json', async t => { test('Transform html witch indent', async t => { t.plan(2); - const filename = tempfile('.html'); + const filename = await tempwrite('', 'output.html'); await execa('../cli.js', ['-i', 'fixtures/input-indent.html', '-o', filename]); t.true(await pathExists(filename)); t.is((await read('expected/output-indent.html')), (await read(filename))); @@ -63,7 +59,7 @@ test('Transform html witch indent', async t => { test('Transform html witch config in file', async t => { t.plan(2); - const filename = tempfile('.html'); + const filename = await tempwrite('', 'output.html'); await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']); t.true(await pathExists(filename)); t.is((await read('expected/output-config-file.html')), (await read(filename))); @@ -71,7 +67,7 @@ test('Transform html witch config in file', async t => { test('Transform html from folder', async t => { t.plan(2); - const folder = tempfile(); + const folder = await tempfile(); await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`))); @@ -79,7 +75,7 @@ test('Transform html from folder', async t => { test('Transform html witch options replace', async t => { t.plan(2); - const folder = tempfile(); + const folder = await tempfile(); await copy(['fixtures/*.html'], `${folder}/`); await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']); 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 => { test('Transform html witch config in file and stdin options use', async t => { t.plan(2); - const filename = tempfile('.html'); + const filename = await tempwrite('', 'output.html'); await execa('../cli.js', [ '-o', filename, From a6afb332c12b10d03bcc2672e42edb2578f0d982 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 16:26:46 +0300 Subject: [PATCH 15/16] Fixed #79, test for windows --- package.json | 1 - test/test-cli.js | 36 ++++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index a09c809..8aba9c6 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "posthtml-bem": "^0.2.2", "posthtml-custom-elements": "^1.0.3", "read-pkg": "^1.1.0", - "temp-write": "^2.1.0", "tempfile": "^1.1.1", "updtr": "^0.1.10", "xo": "^0.15.0" diff --git a/test/test-cli.js b/test/test-cli.js index 7262012..fb335fc 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -5,8 +5,8 @@ const execa = require('execa'); const pathExists = require('path-exists'); const readPkg = require('read-pkg'); const copy = require('cpy'); -const tempwrite = require('temp-write'); const tempfile = require('tempfile'); +const cli = path.resolve('../cli.js'); function read(pathFile) { return new Promise((resolve, reject) => { @@ -20,47 +20,47 @@ function read(pathFile) { } test('Missing required arguments -i, -o', t => { - t.throws(execa('../cli.js', [])); + t.throws(execa(cli, [])); }); test('Missing required arguments -o', t => { - t.throws(execa('../cli.js', ['-i', 'fixtures/input.html'])); + t.throws(execa(cli, ['-i', 'fixtures/input.html'])); }); test('Missing required arguments -i', t => { - const filename = tempwrite.sync('output.html'); - t.throws(execa('../cli.js', ['-o', filename])); + const filename = tempfile('.html'); + t.throws(execa(cli, ['-o', filename])); }); test('One of the arguments', t => { - const filename = tempwrite.sync('output.html'); - t.throws(execa('../cli.js', ['-o', filename, '-r', '-i', 'fixtures/input.html'])); + const filename = tempfile('.html'); + t.throws(execa(cli, ['-o', filename, '-r', '-i', 'fixtures/input.html'])); }); test('Check version', async t => { - t.is((await execa('../cli.js', ['-v'])).stdout, (await readPkg(path.dirname(__dirname))).version); + t.is((await execa(cli, ['-v'])).stdout, (await readPkg(path.dirname(__dirname))).version); }); test('Transform html witch config in package.json', async t => { t.plan(2); - const filename = await tempwrite('', 'output.html'); - await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename]); + const filename = tempfile('.html'); + await execa(cli, ['-i', 'fixtures/input.html', '-o', filename]); t.true(await pathExists(filename)); t.is((await read('expected/output-config-pkg.html')), (await read(filename))); }); test('Transform html witch indent', async t => { t.plan(2); - const filename = await tempwrite('', 'output.html'); - await execa('../cli.js', ['-i', 'fixtures/input-indent.html', '-o', filename]); + const filename = tempfile('.html'); + await execa(cli, ['-i', 'fixtures/input-indent.html', '-o', filename]); t.true(await pathExists(filename)); t.is((await read('expected/output-indent.html')), (await read(filename))); }); test('Transform html witch config in file', async t => { t.plan(2); - const filename = await tempwrite('', 'output.html'); - await execa('../cli.js', ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']); + const filename = tempfile('.html'); + await execa(cli, ['-i', 'fixtures/input.html', '-o', filename, '-c', 'fixtures/config.json']); t.true(await pathExists(filename)); t.is((await read('expected/output-config-file.html')), (await read(filename))); }); @@ -68,7 +68,7 @@ test('Transform html witch config in file', async t => { test('Transform html from folder', async t => { t.plan(2); const folder = await tempfile(); - await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]); + await execa(cli, ['-i', 'fixtures/*.html', '-o', `${folder}/`]); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`))); }); @@ -77,15 +77,15 @@ test('Transform html witch options replace', async t => { t.plan(2); const folder = await tempfile(); await copy(['fixtures/*.html'], `${folder}/`); - await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']); + await execa(cli, ['-i', `${folder}/*.html`, '-r']); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`))); }); test('Transform html witch config in file and stdin options use', async t => { t.plan(2); - const filename = await tempwrite('', 'output.html'); - await execa('../cli.js', [ + const filename = tempfile('.html'); + await execa(cli, [ '-o', filename, '-i', From f4457b4962d0a8fc07b6779537f37633ca3111aa Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 5 May 2016 16:27:15 +0300 Subject: [PATCH 16/16] bump --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d91ddb..12d939c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixed - Fixed linter report error +- Fixed #79, test for windows ## Removed - Remove temp-write now used tempfile