diff --git a/changelog.md b/changelog.md index fa9d859..7cac23f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,17 @@ +## 0.7.1 (2020-08-13) + +* build: update dep dev ([dc8b828](https://github.com/posthtml/posthtml-cli/commit/dc8b828)) +* fix: options for procees from config, close #306 ([f4d3eed](https://github.com/posthtml/posthtml-cli/commit/f4d3eed)), closes [#306](https://github.com/posthtml/posthtml-cli/issues/306) +* test: for options in config, issue #306 ([a0e093a](https://github.com/posthtml/posthtml-cli/commit/a0e093a)), closes [#306](https://github.com/posthtml/posthtml-cli/issues/306) +* test: for resolve options in config ([80b70ff](https://github.com/posthtml/posthtml-cli/commit/80b70ff)) +* perf: resolve options in config ([dbbbee8](https://github.com/posthtml/posthtml-cli/commit/dbbbee8)) + + + ## 0.7.0 (2020-08-10) +* 0.7.0 ([2b605dc](https://github.com/posthtml/posthtml-cli/commit/2b605dc)) +* build: update changelog ([77b8cb5](https://github.com/posthtml/posthtml-cli/commit/77b8cb5)) * build: update dep dev ([129e717](https://github.com/posthtml/posthtml-cli/commit/129e717)) * fix: after change use priority ([5b41e62](https://github.com/posthtml/posthtml-cli/commit/5b41e62)) * fix: override config file options via CLI args, close #304 ([e1f1334](https://github.com/posthtml/posthtml-cli/commit/e1f1334)), closes [#304](https://github.com/posthtml/posthtml-cli/issues/304) diff --git a/package-lock.json b/package-lock.json index 549fca4..8ace6ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "posthtml-cli", - "version": "0.7.0", + "version": "0.7.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3253,9 +3253,9 @@ } }, "acorn": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", - "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.1.tgz", + "integrity": "sha512-dmKn4pqZ29iQl2Pvze1zTrps2luvls2PBY//neO2WJ0s10B3AxJXshN+Ph7B4GrhfGhHXrl4dnUwyNNXQcnWGQ==", "dev": true }, "acorn-jsx": { @@ -3525,7 +3525,8 @@ "arrify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", - "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==", + "dev": true }, "asn1": { "version": "0.2.4", @@ -3636,6 +3637,12 @@ "yargs": "^15.4.1" }, "dependencies": { + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + }, "ansi-styles": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", @@ -4482,9 +4489,9 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" }, "camelcase": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.0.0.tgz", - "integrity": "sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==" + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "camelcase-keys": { "version": "6.2.2", @@ -4494,13 +4501,6 @@ "camelcase": "^5.3.1", "map-obj": "^4.0.0", "quick-lru": "^4.0.1" - }, - "dependencies": { - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" - } } }, "caniuse-lite": { @@ -5650,59 +5650,22 @@ "dev": true }, "conventional-changelog": { - "version": "3.1.22", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.22.tgz", - "integrity": "sha512-bqaHi+NUs5RGO/WjEwSTR+SkVonxZYBEm0dKLY8CDuwz2m0zqNijD8ECAo+08UvJSu6sbFmhVbVUwtvvC+KSoQ==", + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.23.tgz", + "integrity": "sha512-sScUu2NHusjRC1dPc5p8/b3kT78OYr95/Bx7Vl8CPB8tF2mG1xei5iylDTRjONV5hTlzt+Cn/tBWrKdd299b7A==", "dev": true, "requires": { "conventional-changelog-angular": "^5.0.11", "conventional-changelog-atom": "^2.0.7", "conventional-changelog-codemirror": "^2.0.7", - "conventional-changelog-conventionalcommits": "^4.3.1", - "conventional-changelog-core": "^4.1.8", + "conventional-changelog-conventionalcommits": "^4.4.0", + "conventional-changelog-core": "^4.2.0", "conventional-changelog-ember": "^2.0.8", "conventional-changelog-eslint": "^3.0.8", "conventional-changelog-express": "^2.0.5", "conventional-changelog-jquery": "^3.0.10", "conventional-changelog-jshint": "^2.0.8", "conventional-changelog-preset-loader": "^2.3.4" - }, - "dependencies": { - "compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dev": true, - "requires": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, - "conventional-changelog-angular": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.11.tgz", - "integrity": "sha512-nSLypht/1yEflhuTogC03i7DX7sOrXGsRn14g131Potqi6cbGbGEE9PSDEHKldabB6N76HiSyw9Ph+kLmC04Qw==", - "dev": true, - "requires": { - "compare-func": "^2.0.0", - "q": "^1.5.1" - } - }, - "dot-prop": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", - "integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==", - "dev": true, - "requires": { - "is-obj": "^2.0.0" - } - }, - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true - } } }, "conventional-changelog-angular": { @@ -5725,13 +5688,13 @@ } }, "conventional-changelog-cli": { - "version": "2.0.34", - "resolved": "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-2.0.34.tgz", - "integrity": "sha512-HDDIhhpsMKiiAfH/mbj7wApgN7uA33Nk4hISY3/7ijlfqXc/bmP3v4o3Yialoxz0iTBibc94xi6kfTH7XIvwDw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-cli/-/conventional-changelog-cli-2.1.0.tgz", + "integrity": "sha512-hZ8EcpxV4LcGOZwH+U5LJQDnyA4o/uyUdmIGzmFZMB4caujavvDBo/iTgVihk0m1QKkEhJgulagrILSm1JCakA==", "dev": true, "requires": { "add-stream": "^1.0.0", - "conventional-changelog": "^3.1.21", + "conventional-changelog": "^3.1.23", "lodash": "^4.17.15", "meow": "^7.0.0", "tempfile": "^3.0.0" @@ -5747,47 +5710,20 @@ } }, "conventional-changelog-conventionalcommits": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.3.1.tgz", - "integrity": "sha512-EQa7TJzF7H4EMkfjjJV7d+gragejDqa8NirZnCfRpruCMZqRbAJ8DqmYbkHrYtBYicXqgfM0zkk6HlvLPcyOdQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.4.0.tgz", + "integrity": "sha512-ybvx76jTh08tpaYrYn/yd0uJNLt5yMrb1BphDe4WBredMlvPisvMghfpnJb6RmRNcqXeuhR6LfGZGewbkRm9yA==", "dev": true, "requires": { "compare-func": "^2.0.0", "lodash": "^4.17.15", "q": "^1.5.1" - }, - "dependencies": { - "compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dev": true, - "requires": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, - "dot-prop": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", - "integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==", - "dev": true, - "requires": { - "is-obj": "^2.0.0" - } - }, - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true - } } }, "conventional-changelog-core": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.1.8.tgz", - "integrity": "sha512-M7VWA/RiVyjXIVt3SdfbgZFh0se67WBl78EzIYlBlFmDszzb00BwHlaNpgR1XrN0v56vtfBVq1sKEwQo2HbmkA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.2.0.tgz", + "integrity": "sha512-8+xMvN6JvdDtPbGBqA7oRNyZD4od1h/SIzrWqHcKZjitbVXrFpozEeyn4iI4af1UwdrabQpiZMaV07fPUTGd4w==", "dev": true, "requires": { "add-stream": "^1.0.0", @@ -5797,7 +5733,7 @@ "get-pkg-repo": "^1.0.0", "git-raw-commits": "2.0.0", "git-remote-origin-url": "^2.0.0", - "git-semver-tags": "^4.0.0", + "git-semver-tags": "^4.1.0", "lodash": "^4.17.15", "normalize-package-data": "^2.3.5", "q": "^1.5.1", @@ -6092,33 +6028,6 @@ "requires": { "compare-func": "^2.0.0", "q": "^1.5.1" - }, - "dependencies": { - "compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dev": true, - "requires": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, - "dot-prop": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", - "integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==", - "dev": true, - "requires": { - "is-obj": "^2.0.0" - } - }, - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true - } } }, "conventional-changelog-preset-loader": { @@ -6143,33 +6052,6 @@ "semver": "^6.0.0", "split": "^1.0.0", "through2": "^3.0.0" - }, - "dependencies": { - "compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dev": true, - "requires": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, - "dot-prop": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", - "integrity": "sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A==", - "dev": true, - "requires": { - "is-obj": "^2.0.0" - } - }, - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true - } } }, "conventional-commits-filter": { @@ -7269,6 +7151,14 @@ "acorn": "^7.3.1", "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.3.0" + }, + "dependencies": { + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + } } }, "glob-parent": { @@ -7622,6 +7512,14 @@ "acorn": "^7.3.1", "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.3.0" + }, + "dependencies": { + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + } } }, "pkg-dir": { @@ -9041,9 +8939,9 @@ } }, "git-semver-tags": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-4.0.0.tgz", - "integrity": "sha512-LajaAWLYVBff+1NVircURJFL8TQ3EMIcLAfHisWYX/nPoMwnTYfWAznQDmMujlLqoD12VtLmoSrF1sQ5MhimEQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-4.1.0.tgz", + "integrity": "sha512-TcxAGeo03HdErzKzi4fDD+xEL7gi8r2Y5YSxH6N2XYdVSV5UkBwfrt7Gqo1b+uSHCjy/sa9Y6BBBxxFLxfbhTg==", "dev": true, "requires": { "meow": "^7.0.0", @@ -11577,17 +11475,15 @@ } }, "meow": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-7.0.1.tgz", - "integrity": "sha512-tBKIQqVrAHqwit0vfuFPY3LlzJYkEOFyKa3bPgxzNl6q/RtN8KQ+ALYEASYuFayzSAsjlhXj/JZ10rH85Q6TUw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-7.1.0.tgz", + "integrity": "sha512-kq5F0KVteskZ3JdfyQFivJEj2RaA8NFsS4+r9DaMKLcUHpk5OcHS3Q0XkCXONB1mZRPsu/Y/qImKri0nwSEZog==", "requires": { "@types/minimist": "^1.2.0", - "arrify": "^2.0.1", - "camelcase": "^6.0.0", "camelcase-keys": "^6.2.2", "decamelize-keys": "^1.1.0", "hard-rejection": "^2.1.0", - "minimist-options": "^4.0.2", + "minimist-options": "4.1.0", "normalize-package-data": "^2.5.0", "read-pkg-up": "^7.0.1", "redent": "^3.0.0", @@ -12771,12 +12667,12 @@ "dev": true }, "posthtml": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.13.1.tgz", - "integrity": "sha512-8aJZ63WYL9YsAZVcrIn6U0dSYbna7hcTceZjnbH7dilg01t4t3JDx0UovbhGFscFJg/++qhECCjGEQuJAqD7dA==", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.13.2.tgz", + "integrity": "sha512-WVXgLnzwget6xI+yOV/eujHKC7+057+smtImFkd4l/szxWZ4wmU0wF+JH+RX6x1+iqB0F8019XKOzETPJ/iGHg==", "requires": { "posthtml-parser": "^0.4.2", - "posthtml-render": "^1.2.2" + "posthtml-render": "^1.2.3" } }, "posthtml-attrs-parser": { diff --git a/package.json b/package.json index 78f2934..86f416c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthtml-cli", - "version": "0.7.0", + "version": "0.7.1", "description": "CLI for posthtml", "license": "MIT", "repository": "posthtml/posthtml-cli", @@ -23,7 +23,7 @@ "build": "rimraf lib && babel src -d lib", "coverage": "nyc report --reporter=text-lcov | coveralls", "pretest": "npm run build", - "test": "nyc ava --timeout=1m --verbose" + "test": "nyc ava test/test-cli.js --timeout=1m --verbose" }, "files": [ "lib/" @@ -37,9 +37,9 @@ "cosmiconfig": "^7.0.0", "fast-glob": "^3.2.4", "make-dir": "^3.0.0", - "meow": "^7.0.1", + "meow": "^7.1.0", "merge-options": "^2.0.0", - "posthtml": "^0.13.1", + "posthtml": "^0.13.2", "to-camel-case": "^1.0.0" }, "devDependencies": { @@ -50,12 +50,12 @@ "@babel/register": "^7.10.5", "@commitlint/cli": "^9.1.1", "@commitlint/config-angular": "^9.1.1", - "acorn": "^7.4.0", + "acorn": "^8.0.1", "ava": "^3.11.1", "babel-eslint": "^10.0.3", "babel-preset-minify": "^0.5.1", "clinton": "^0.14.0", - "conventional-changelog-cli": "^2.0.31", + "conventional-changelog-cli": "^2.1.0", "coveralls": "^3.0.9", "cpy": "^8.0.0", "eslint": "^7.6.0", diff --git a/src/cfg-resolve.js b/src/cfg-resolve.js index 85b2998..07b5a44 100644 --- a/src/cfg-resolve.js +++ b/src/cfg-resolve.js @@ -4,7 +4,7 @@ import mergeOptions from 'merge-options'; export default ({input, flags = {}}) => { const explorer = cosmiconfigSync('posthtml'); - let {config, use, output, root = './', allInOutput} = flags; + let {config, use, options = {}, output, root = './', allInOutput} = flags; if (config) { ({config} = explorer.load(config)); @@ -21,6 +21,7 @@ export default ({input, flags = {}}) => { return mergeOptions(config || {}, { input, output, + options, root, allInOutput }, use || {}); diff --git a/src/cli.js b/src/cli.js index 9a28b56..cc2286b 100755 --- a/src/cli.js +++ b/src/cli.js @@ -53,6 +53,11 @@ const cli = meow(` alias: 'u', isMultiple: true }, + // https://github.com/sindresorhus/meow/issues/158 + // options: { + // type: 'string', + // isMultiple: true + // }, root: { type: 'string', alias: 'r', @@ -65,13 +70,15 @@ const cli = meow(` } }); -const read = file => new Promise(resolve => fs.readFile(file, 'utf8', (error, data) => { - if (error) { - console.warn(error); - } +const read = file => new Promise(resolve => { + fs.readFile(file, 'utf8', (error, data) => { + if (error) { + console.warn(error); + } - resolve(data); -})); + resolve(data); + }); +}); const interopRequire = object => object && object.__esModule ? object.default : object; @@ -86,7 +93,7 @@ const processing = async file => { makeDir(path.dirname(output)) .then(read.bind(undefined, file)) - .then(html => posthtml(plugins).process(html)) + .then(html => Promise.resolve(posthtml(plugins).process(html, config.options))) .then(({html}) => { fs.writeFile(output, html, error => { if (error) { diff --git a/test/config/.config-options b/test/config/.config-options new file mode 100644 index 0000000..e793c0d --- /dev/null +++ b/test/config/.config-options @@ -0,0 +1,5 @@ +{ + 'options': { + sync: true + } +} diff --git a/test/expected/by-config/options/output.html b/test/expected/by-config/options/output.html new file mode 100644 index 0000000..fb00d6b --- /dev/null +++ b/test/expected/by-config/options/output.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + + + diff --git a/test/fixtures/by-config/options/.config b/test/fixtures/by-config/options/.config new file mode 100644 index 0000000..d0b910a --- /dev/null +++ b/test/fixtures/by-config/options/.config @@ -0,0 +1,7 @@ +{ + input: 'test/fixtures/by-config/options/input.html', + output: 'test/expected/by-config/options/output.html', + options: { + directives: [{name: '?php', start: '<', end: '>'}] + } +} diff --git a/test/fixtures/by-config/options/input.html b/test/fixtures/by-config/options/input.html new file mode 100644 index 0000000..fb00d6b --- /dev/null +++ b/test/fixtures/by-config/options/input.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + + + diff --git a/test/test-cfg-resolve.js b/test/test-cfg-resolve.js index a477a41..5393ce9 100644 --- a/test/test-cfg-resolve.js +++ b/test/test-cfg-resolve.js @@ -28,7 +28,7 @@ test('should return config with one use key with one property', async t => { t.deepEqual(config.plugins, expected); }); -test('should return config with key config', async t => { +test('should return config with key config plugins', async t => { const flags = { config: 'test/config/.config-plugins' }; @@ -38,6 +38,26 @@ test('should return config with key config', async t => { t.deepEqual(config.plugins, expected); }); +test('should return config with key config options', async t => { + const flags = { + config: 'test/config/.config-options' + }; + const config = await cfgResolve({flags}); + const expected = {sync: true}; + + t.deepEqual(config.options, expected); +}); + +test('should return config options', async t => { + const flags = { + options: {sync: true} + }; + const config = await cfgResolve({flags}); + const expected = {sync: true}; + + t.deepEqual(config.options, expected); +}); + test('should return config with key config and use key', async t => { const flags = { use: 'posthtml-assets', @@ -55,13 +75,8 @@ test('should return config when CLI params priority', async t => { config: 'test/config/.config-input-priority' }; const config = await cfgResolve({input, flags}); - const expected = { - allInOutput: undefined, - input: 'src/template/**/*.html', - output: undefined, - root: './' - }; + const expected = 'src/template/**/*.html'; - t.deepEqual(config, expected); + t.deepEqual(config.input, expected); }); diff --git a/test/test-cli.js b/test/test-cli.js index 77fe249..0f1aea1 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -8,13 +8,15 @@ import readPkg from 'read-pkg'; import tempfile from 'tempfile'; const cli = path.resolve('lib/cli.js'); -const read = file => new Promise((resolve, reject) => fs.readFile(file, 'utf8', (error, data) => { - if (error) { - return reject(error); - } +const read = file => new Promise((resolve, reject) => { + fs.readFile(file, 'utf8', (error, data) => { + if (error) { + return reject(error); + } - resolve(data); -})); + resolve(data); + }); +}); test('Check version', async t => { const {stdout} = await execa(cli, ['-v']); @@ -145,6 +147,19 @@ test('Transform html stdin options use witch modules', async t => { t.is((await read('test/expected/output-modules.html')), (await read(filename))); }); +test('Transform html stdin options', async t => { + t.plan(2); + await execa(cli, [ + '-c', + 'test/fixtures/by-config/options/.config' + ]); + t.true(await pathExists('test/expected/by-config/options/output.html')); + t.is( + (await read('test/expected/by-config/options/output.html')), + (await read('test/fixtures/by-config/options/input.html')) + ); +}); + test('Transform html stdin options only config one-io', async t => { t.plan(2); await execa(cli, [