diff --git a/.editorconfig b/.editorconfig index e7b73a7a..aaa39996 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,13 +1,18 @@ -# https://editorconfig.org +# EditorConfig is Awesome: http://editorconfig.org + +# Top-most EditorConfig file. root = true +# Unix-style newlines with a newline ending every file. [*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 indent_style = space indent_size = 2 -charset = utf-8 trim_trailing_whitespace = true -insert_final_newline = true -end_of_line = lf +# Don't trim whitespace in Markdown in order to be able +# to do two spaces for line breaks. [*.md] trim_trailing_whitespace = false diff --git a/.eslintrc b/.eslintrc index c35bface..a5a4a173 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,3 @@ { - "extends": "gulp", - "rules": { - "max-len": [1, 130], - "max-statements": [1, 65], - "no-console": "off" - } + "extends": "gulp" } diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index fcadb2cf..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text eol=lf diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml deleted file mode 100644 index 9e3fe6a8..00000000 --- a/.github/workflows/dev.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: dev -on: - pull_request: - push: - branches: - - master - - main -env: - CI: true - -jobs: - prettier: - name: Format code - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Prettier - uses: gulpjs/prettier_action@v3.0 - with: - commit_message: 'chore: Run prettier' - prettier_options: '--write .' - - test: - name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - node: [10, 12, 14, 16, 18, 20, 22, 24] - os: [ubuntu-latest, windows-latest, macos-13] - - steps: - - name: Clone repository - uses: actions/checkout@v2 - - - name: Set Node.js version - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - - run: node --version - - run: npm --version - - - name: Install npm dependencies - run: npm install - - - name: Run lint - run: npm run lint - - - name: Run tests - # Run test without coverage because a behavior about esm is different with nyc or not - run: npm test - - coveralls: - needs: test - name: Finish up - - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v2 - - - name: Set Node.js version - uses: actions/setup-node@v2 - with: - # Coverage with LTS version - node-version: 18 - - - run: node --version - - run: npm --version - - - name: Install npm dependencies - run: npm install - - - name: Run coverage - run: npm run cover - - - name: Coveralls - uses: coverallsapp/github-action@v1.1.2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 87cd13c0..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: release -on: - push: - branches: - - master - - main - -jobs: - release-please: - runs-on: ubuntu-latest - steps: - - uses: GoogleCloudPlatform/release-please-action@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - release-type: node - package-name: release-please-action diff --git a/.gitignore b/.gitignore index c626059e..f2f8f37a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ .DS_Store *.log node_modules -!test/fixtures/errors/bad-gulp-version/node_modules/ -!test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/node_modules/ build *.node components diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 00000000..9f7071c3 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,4 @@ +{ + "preset": "gulp", + "excludeFiles": ["**/*.babel.js"] +} diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 43c97e71..00000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index c96ebe0c..00000000 --- a/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -coverage/ -.nyc_output/ -CHANGELOG.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..cb48a3c2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +sudo: false +language: node_js +node_js: + - "6" + - "4" + - "0.12" + - "0.10" +before_script: + - sed -i 's/4.0.0-alpha.1/4.0.0/g' node_modules/gulp/package.json +after_script: + - npm run coveralls + - npm run lint +git: + depth: 10 diff --git a/CHANGELOG.md b/CHANGELOG.md index 682048ab..a13b88ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,162 @@ -# Changelog - -## [3.1.0](https://www.github.com/gulpjs/gulp-cli/compare/v3.0.0...v3.1.0) (2025-06-01) - - -### Features - -* Support top-level await on Node 22.12+ ([#269](https://www.github.com/gulpjs/gulp-cli/issues/269)) ([902f5b2](https://www.github.com/gulpjs/gulp-cli/commit/902f5b28f1979b40b29e183086796387584ae1ec)) - -## [3.0.0](https://www.github.com/gulpjs/gulp-cli/compare/v2.3.0...v3.0.0) (2024-03-24) - - -### ⚠ BREAKING CHANGES - -* Only allow js variants for `.gulp` config files (#261) -* Upgrade to Liftoff v5 and avoid merging flags/config/env (#259) -* Remove support for alpha versions of gulp 4 (#255) -* Remove `--verify` flag (#251) -* Replace `--require` flag with `--preload` -* Normalize repository, dropping node <10.13 support (#239) - -### Features - -* Add deprecated warning for gulplog v1 messages ([#266](https://www.github.com/gulpjs/gulp-cli/issues/266)) ([affeda9](https://www.github.com/gulpjs/gulp-cli/commit/affeda9e01569511cd34f1fe7f66d5ad75339624)) -* Add versioned handler for gulp v5 ([#265](https://www.github.com/gulpjs/gulp-cli/issues/265)) ([f06ff30](https://www.github.com/gulpjs/gulp-cli/commit/f06ff30eb6dfa7db0a3b2935a76d79609a54016e)) -* Support theming and translations via config files ([#260](https://www.github.com/gulpjs/gulp-cli/issues/260)) ([e16d675](https://www.github.com/gulpjs/gulp-cli/commit/e16d675606867a5a3a64c24e7fa48bb0a664723d)) -* Upgrade to Liftoff v5 and avoid merging flags/config/env ([#259](https://www.github.com/gulpjs/gulp-cli/issues/259)) ([ed86da7](https://www.github.com/gulpjs/gulp-cli/commit/ed86da75fddfe0965d9bcc0a299e74f961f50957)) - - -### Bug Fixes - -* Ensure the logger is wired up before running liftoff ([#258](https://www.github.com/gulpjs/gulp-cli/issues/258)) ([36f05d5](https://www.github.com/gulpjs/gulp-cli/commit/36f05d5a8bb5c56437204a37f12fc4b2e31c5430)) - - -### Miscellaneous Chores - -* Normalize repository, dropping node <10.13 support ([#239](https://www.github.com/gulpjs/gulp-cli/issues/239)) ([3544dc6](https://www.github.com/gulpjs/gulp-cli/commit/3544dc65138c6409758c28e083ea1d93640246d8)) -* Only allow js variants for `.gulp` config files ([#261](https://www.github.com/gulpjs/gulp-cli/issues/261)) ([e5c7983](https://www.github.com/gulpjs/gulp-cli/commit/e5c79839e87154aa5bc5d8888eeba29314b17fc6)) -* Remove `--verify` flag ([#251](https://www.github.com/gulpjs/gulp-cli/issues/251)) ([7aeee5d](https://www.github.com/gulpjs/gulp-cli/commit/7aeee5d82e09099696f44fae25d315ef31c14030)) -* Remove support for alpha versions of gulp 4 ([#255](https://www.github.com/gulpjs/gulp-cli/issues/255)) ([cb03b9a](https://www.github.com/gulpjs/gulp-cli/commit/cb03b9a6698ead4537d77bd0478947366b7d29a6)) -* Replace `--require` flag with `--preload` ([3544dc6](https://www.github.com/gulpjs/gulp-cli/commit/3544dc65138c6409758c28e083ea1d93640246d8)) +## Change Log + +### upcoming (2016/03/03 00:36 +00:00) +- [2579884](https://github.com/gulpjs/gulp-cli/commit/2579884f3945f1597524eb68ef2b31b0e070cb12) update tests to reflect undertaker updates (@phated) +- [#58](https://github.com/gulpjs/gulp-cli/pull/58) Add changelog (@Xiphe) +- [#64](https://github.com/gulpjs/gulp-cli/pull/64) Avoid locking errors on AppVeyor (@sttk) +- [07b061c](https://github.com/gulpjs/gulp-cli/commit/07b061cf6f689fd9871bdd3ff7f6bc6164a10d03) Change to specifying npm version only in verion 0.10 of node.js (@sttk) +- [8dc8e6e](https://github.com/gulpjs/gulp-cli/commit/8dc8e6ea1ee6da0bf04a2980d214b8a97da53b9c) Avoid locking errors on AppVeyor (@sttk) + +### v1.2.1 (2016/02/09 20:47 +00:00) +- [fef30d8](https://github.com/gulpjs/gulp-cli/commit/fef30d8de1dc32437fe796c7c07e94e58abd71bb) 1.2.1 (@phated) +- [0af0e01](https://github.com/gulpjs/gulp-cli/commit/0af0e01f3e605f86b77e1f7909a709e16be38796) back out displayName change from #53 - add regression test (@phated) +- [7d56090](https://github.com/gulpjs/gulp-cli/commit/7d56090c29da791e351c448e358a01f5a5372379) add example usage (@phated) +- [745d2c2](https://github.com/gulpjs/gulp-cli/commit/745d2c230892aaaa5c6b3493c88a3b04b30d365e) docs: add initial changelog (@Xiphe) +- [c80b6b2](https://github.com/gulpjs/gulp-cli/commit/c80b6b2eff1e5ec0343744ba4b7f7eae922a25be) chore: add NPM script for changelog (@Xiphe) + +### v1.2.0 (2016/01/31 20:01 +00:00) +- [962d465](https://github.com/gulpjs/gulp-cli/commit/962d46545b60acfad95807b4eacd59cee7e7e6be) 1.2.0 (@phated) +- [c6aba4a](https://github.com/gulpjs/gulp-cli/commit/c6aba4a09abf95af2aaf2578fd365b7f8fded245) Add custom metadata docs (@phated) +- [1a2f553](https://github.com/gulpjs/gulp-cli/commit/1a2f5530bc97cf102744875d529e61721b52d19c) better labels (@phated) +- [fb7fcaf](https://github.com/gulpjs/gulp-cli/commit/fb7fcaf6ddcdd3bf7e9731bd0335750cb949434a) add appveyor badge (@phated) +- [6aa13f0](https://github.com/gulpjs/gulp-cli/commit/6aa13f0226685905f032e431d1cebd87fc4ae882) cleanup (@phated) +- [61a02d6](https://github.com/gulpjs/gulp-cli/commit/61a02d68255b422010c941c3c47e913b25495e74) # This is a combination of 4 commits. (@sttk) + +### v1.1.1 (2016/01/29 18:57 +00:00) +- [07984b6](https://github.com/gulpjs/gulp-cli/commit/07984b6e20550cce410040c1c37255a709d46b9c) 1.1.1 (@phated) +- [#53](https://github.com/gulpjs/gulp-cli/pull/53) add displayName support to exported tasks (@nmn) +- [b7da669](https://github.com/gulpjs/gulp-cli/commit/b7da669f8e9454f6b27da8afada04392797ef396) add displayName support to exported tasks (@nmn) +- [#52](https://github.com/gulpjs/gulp-cli/pull/52) Fixed AppVeyor errors. (@sttk) +- [7845ae7](https://github.com/gulpjs/gulp-cli/commit/7845ae7f87094442511873d58806f7c28129a0ba) Fixed AppVeyor errors. (@sttk) + +### v1.1.0 (2015/12/21 23:37 +00:00) +- [41cead7](https://github.com/gulpjs/gulp-cli/commit/41cead78fa5e661304e193d7c0c034caf073671b) 1.1.0 +- [#48](https://github.com/gulpjs/gulp-cli/pull/48) move branches to debug log (@gulpjs) +- [3d28be6](https://github.com/gulpjs/gulp-cli/commit/3d28be62efcc5e02152de181a3d9c8c52f7aa107) move branches to debug log +- [#47](https://github.com/gulpjs/gulp-cli/pull/47) register any function that is exported from a gulpfile (@gulpjs) +- [80ba208](https://github.com/gulpjs/gulp-cli/commit/80ba20846df07e8bac8c8be3593dd41f4fbcee1b) cleanup and backport +- [9d9013d](https://github.com/gulpjs/gulp-cli/commit/9d9013d471051261af15720748ff86879c5b11ef) register any function that is exported from a gulpfile +- [#46](https://github.com/gulpjs/gulp-cli/pull/46) Track logged errors (@gulpjs) +- [af74029](https://github.com/gulpjs/gulp-cli/commit/af740292dc4bfdc362ff672bf9622043afa2a2e0) fix jscs linting +- [6f23077](https://github.com/gulpjs/gulp-cli/commit/6f23077406c5f21d0457647ca4f636d817549f0c) rename `e` event to avoid confusing with `e` for error +- [f9834f7](https://github.com/gulpjs/gulp-cli/commit/f9834f73a8fe97d843bf6b160ac72563aa900c0b) track errors we log and only log them once + +### v1.0.0 (2015/11/18 23:50 +00:00) +- [5e121b6](https://github.com/gulpjs/gulp-cli/commit/5e121b6180e1f2d6de81afcb0cf069bedc1c7dd1) 1.0.0 +- [30e7ec4](https://github.com/gulpjs/gulp-cli/commit/30e7ec44b07bce9a3b1a1f31778d575697b99357) bump interpret dep +- [622db18](https://github.com/gulpjs/gulp-cli/commit/622db18863b4b1e1053abf645a051173188e328a) bump mute-stdout dep +- [7fa14fc](https://github.com/gulpjs/gulp-cli/commit/7fa14fcd2bf2fb2de43227596e3bf2f95763632d) update README and man page +- [44a14e5](https://github.com/gulpjs/gulp-cli/commit/44a14e53192e3f5c91c05012b8d6d590dc1b093d) using package.json files property so no need for npmignore +- [d4c2fc7](https://github.com/gulpjs/gulp-cli/commit/d4c2fc7f0c55ba388c3b201bb901a98bc5c824a7) run appveyor CI on node 4 and 5 +- [a99a031](https://github.com/gulpjs/gulp-cli/commit/a99a03190d6326c7716eb368b8bfd7af603d1465) update package.json +- [62a896e](https://github.com/gulpjs/gulp-cli/commit/62a896e5da8d82a8de2ecf3439bbb8f75262751f) ^4.0.0 support which is a mirror of alpha.2 logic +- [565cf68](https://github.com/gulpjs/gulp-cli/commit/565cf68ab6c543931d20e3d559f8ac214cc53921) ignore test output +- [e69cfdc](https://github.com/gulpjs/gulp-cli/commit/e69cfdc83770100d0f3841f9f19e95099661d85e) make CLI support new undertaker tree return value +- [b4cbc14](https://github.com/gulpjs/gulp-cli/commit/b4cbc14e7e2ce22a2325ccfae785e7d1420b52e6) add license file +- [9bc66cc](https://github.com/gulpjs/gulp-cli/commit/9bc66cc10b432f8a30c538761fc071d49ef5c5e3) Improve task not found messaging (@soulcutter) +- [7387dec](https://github.com/gulpjs/gulp-cli/commit/7387decbd4322c71aef5083fd6a01126d6994af0) reorganize package.json +- [d543afc](https://github.com/gulpjs/gulp-cli/commit/d543afcee30874a74b773ec78443ff8b9bc761ce) temporarily update gulp version for travis tests +- [0fd9075](https://github.com/gulpjs/gulp-cli/commit/0fd9075968c8f9038ced6c770137d75b3d30f4ad) linting and cleanup +- [72592bd](https://github.com/gulpjs/gulp-cli/commit/72592bd125c8a20f9d68837882780273dacaaa1c) bump yargs for awesome CLI fixes +- [c26cf2e](https://github.com/gulpjs/gulp-cli/commit/c26cf2ed3e0bb829323312f47ad32544668d9ce9) add usage docs + options - closes #38 +- [6f367a6](https://github.com/gulpjs/gulp-cli/commit/6f367a671f05485b5d387d6c6e575ecf36be41d5) Added more integration tests, switch to gulp 4 for devDep (@Romanx) +- [bda8ac3](https://github.com/gulpjs/gulp-cli/commit/bda8ac3a7381f5ef9b4b565e8b251539fde05a6a) bump deps +- [b86ea81](https://github.com/gulpjs/gulp-cli/commit/b86ea8103e5b3ac6f634a44b3a4da9889d564049) fix license property +- [d0fba75](https://github.com/gulpjs/gulp-cli/commit/d0fba7525cda9ca353a317ea05ad7f47bd2268f0) Added some integration tests (@Romanx) +- [f44cfa7](https://github.com/gulpjs/gulp-cli/commit/f44cfa71df06cdefcf6498a1ec98584ee0ecd29b) Added tests for require module option (@Romanx) +- [b45beeb](https://github.com/gulpjs/gulp-cli/commit/b45beebbdaf33a73421469e2b467a24688a07e0c) Package path should no longer be relative (@Romanx) +- [9ec3baa](https://github.com/gulpjs/gulp-cli/commit/9ec3baa1baa431c7038ccbb2aa03e28a6b162346) Verify pkgPath should use env.cwd (@Romanx) +- [92e0356](https://github.com/gulpjs/gulp-cli/commit/92e03568d3178f947caa1f2355385c21b4719bdf) Add task not completed warnings +- [832a6a5](https://github.com/gulpjs/gulp-cli/commit/832a6a5de53c98dcbd771f1488d21dd5897ede1e) avoid marking --tasks-json as string to catch booleans - closes #41 +- [320c02c](https://github.com/gulpjs/gulp-cli/commit/320c02c3fef35a41829f1caebdb6f3dde365524e) update taskTree test to be more clear +- [62a7cae](https://github.com/gulpjs/gulp-cli/commit/62a7cae69bf23116184551772b1f82e85358ea89) use 1.0.0 of gulplog +- [7baf41f](https://github.com/gulpjs/gulp-cli/commit/7baf41f580d0d656cc6ea0438dc66eba7d134c07) update yargs and switch aliases plus some cleanup +- [ec9f42a](https://github.com/gulpjs/gulp-cli/commit/ec9f42aba7c2c37a429efb760d8a6e1841bee433) introduce gulplog and wire up listener (@kahlil) +- [08ad295](https://github.com/gulpjs/gulp-cli/commit/08ad295fc2c3105c57b06987e834f8b7a03731ca) allow an output file to be specified for --tasks-json option - ref #24 +- [f6aec36](https://github.com/gulpjs/gulp-cli/commit/f6aec36d11fc13a159ea08daa015b5a241cfa594) mute stream when listing tasks - closes #24 +- [5376c22](https://github.com/gulpjs/gulp-cli/commit/5376c22414517b77fe2e15ea97ff258102473b44) make things work with babel change +- [5e82b4f](https://github.com/gulpjs/gulp-cli/commit/5e82b4fc39db8bbd863afc19619121ce7899689b) add support for settling (--continue flag) +- [0226d55](https://github.com/gulpjs/gulp-cli/commit/0226d5584ecad0cf6132b1414ac012755957c334) Fix #19 support tasks description +- [a8371e0](https://github.com/gulpjs/gulp-cli/commit/a8371e0bb0a8b810920bab62c303e82a8fad5f10) DRY tasks.js +- [3870672](https://github.com/gulpjs/gulp-cli/commit/38706722754fb13c61056f9be9d830f72f9c4e10) Fix dependency regex in logTasks +- [d42fb9e](https://github.com/gulpjs/gulp-cli/commit/d42fb9ef6c42aa36963dde73be7539f3c70f68b9) Fix typo (@NicoSantangelo) +- [298df67](https://github.com/gulpjs/gulp-cli/commit/298df672683eb2a7e35f9cf1e6084c67213778ba) Update cliOptions.js (@stramel) +- [94c07da](https://github.com/gulpjs/gulp-cli/commit/94c07da0dd7ce46feead00fcffc9d58429774795) use `.task` to get the task - closes #28 +- [6e698e4](https://github.com/gulpjs/gulp-cli/commit/6e698e4be72c72aac1e6dd6debd83c64481c4201) make lint pass +- [5235056](https://github.com/gulpjs/gulp-cli/commit/52350568af409e8e21f8c9a4454cb8a699fe6bd5) initial commit to support 3.x & 4.0 +- [52ef399](https://github.com/gulpjs/gulp-cli/commit/52ef3996e5789a7ef4519fadaf9bafa795c5dd4a) fix autocompletion (@heikki) +- [fccc041](https://github.com/gulpjs/gulp-cli/commit/fccc041ec0a39b9b46566114e6bbcd0692a25944) fix lint +- [ae4f954](https://github.com/gulpjs/gulp-cli/commit/ae4f954dcf2a241bdd4a84879408239a2c260bfa) switch nomnom for yargs +- [8dfc1f1](https://github.com/gulpjs/gulp-cli/commit/8dfc1f17a6fe5c493e86b045c87a8cde3e89040a) cleanup for unsupported versions +- [76ae4d2](https://github.com/gulpjs/gulp-cli/commit/76ae4d278414d62014fa397c03c4277c854b987a) reorg file structure and add version matching based on semver ranges +- [1629465](https://github.com/gulpjs/gulp-cli/commit/1629465078e3fd8a6c1843e3eac30cf2ae950038) fix require path (@heikki) +- [b0fa8f8](https://github.com/gulpjs/gulp-cli/commit/b0fa8f8f412cbd667b4258d877748c8cf08de322) rename versioned directory +- [#43](https://github.com/gulpjs/gulp-cli/pull/43) Switching to ESLint (@pdehaan) +- [2360108](https://github.com/gulpjs/gulp-cli/commit/2360108ebba136a76cdb77981cc91c0a912c11e5) Remove glob from JSCS lint (@pdehaan) +- [2a49e20](https://github.com/gulpjs/gulp-cli/commit/2a49e2056dc0cb8093d093f7a0af54232e863297) Bump eslint-config-gulp and jscs-preset-gulp deps (@pdehaan) +- [57f069b](https://github.com/gulpjs/gulp-cli/commit/57f069b6a59d819aab91896febb53e31cb2623c9) Switching to ESLint (@pdehaan) +- [#44](https://github.com/gulpjs/gulp-cli/pull/44) Switching to jscs-preset-gulp preset (@pdehaan) +- [6b9e1c0](https://github.com/gulpjs/gulp-cli/commit/6b9e1c0ebc55a4a73f14e8c9c6d928099a846b7f) Switching to jscs-preset-gulp preset (@pdehaan) + +### v0.3.0 (2015/07/12 22:42 +00:00) +- [27ff409](https://github.com/gulpjs/gulp-cli/commit/27ff409116ddd5a6af29d54cecc94c69c4bf4162) 0.3.0 +- [3afeb5d](https://github.com/gulpjs/gulp-cli/commit/3afeb5de9225b500e4a1466895483965cadabb82) bump v8flags +- [07efb57](https://github.com/gulpjs/gulp-cli/commit/07efb57bf03d5c30a176f23cb9774eafedbac823) bump liftoff +- [90fe665](https://github.com/gulpjs/gulp-cli/commit/90fe665fe97743315e5e20b7eb287a4aea425538) remove 6to5 tests and deps, switch to labs lcov report +- [82115c2](https://github.com/gulpjs/gulp-cli/commit/82115c2d7c8a56c7cb6a4de619a0d6513b40e4ad) make linting pass +- [f5e4281](https://github.com/gulpjs/gulp-cli/commit/f5e42811d3640bd7325ba64e63d7c71e08b91096) update deps +- [#23](https://github.com/gulpjs/gulp-cli/pull/23) Fix badges (@austinpray) +- [f927620](https://github.com/gulpjs/gulp-cli/commit/f927620cbe8c309caae7983f689cfb09fa9363c4) Fix badges (@austinpray) + +### v0.2.0 (2015/03/22 03:56 +00:00) +- [ef6fef2](https://github.com/gulpjs/gulp-cli/commit/ef6fef27998309073d6c8c3606e57e3414c0e0a9) 0.2.0 +- [47fb9be](https://github.com/gulpjs/gulp-cli/commit/47fb9be67a50f2a1fab545a9b5e0cf26c02e2c32) bring JSCS over from gulp and fix formatting +- [58c4c53](https://github.com/gulpjs/gulp-cli/commit/58c4c53dd3c9a3f6fc9d6f802606dd3dd170efc9) Fix dependency regex +- [c559f79](https://github.com/gulpjs/gulp-cli/commit/c559f798b9e7e4a791a64eb5ddf6d72ba5944623) fix #19 Support description (@louisremi) +- [#18](https://github.com/gulpjs/gulp-cli/pull/18) remove engineStrict (@suyash) +- [e05a13f](https://github.com/gulpjs/gulp-cli/commit/e05a13f47157493b3693386d1ad6e3bf4ab10ca6) remove engineStrict (@suyash) +- [#16](https://github.com/gulpjs/gulp-cli/pull/16) Updates chalk to 1.0.0. (@jbnicolai) +- [9c81da4](https://github.com/gulpjs/gulp-cli/commit/9c81da43a9c411930d9719e60f7a2087c50a3472) Updates chalk to 1.0.0. (@jbnicolai) +- [f5716fe](https://github.com/gulpjs/gulp-cli/commit/f5716fe72333d3a3b1d994ac545100b37748f42d) fix readme grammar (@contra) +- [7ae62f9](https://github.com/gulpjs/gulp-cli/commit/7ae62f9007b86093d97846716f33af8f6628e8e7) increase test timeout to fix failing windows tests (@heikki) +- [9a78e5f](https://github.com/gulpjs/gulp-cli/commit/9a78e5fedcb58beea4292bc1e1cf53231ef24532) Update appveyor.yml (@heikki) +- [b7a2203](https://github.com/gulpjs/gulp-cli/commit/b7a2203f96afdeb5a9b093fa6450e60f8ff2d6a4) Update .travis.yml (@sindresorhus) + +### v0.1.5 (2015/01/18 22:50 +00:00) +- [f323e4d](https://github.com/gulpjs/gulp-cli/commit/f323e4d312491bce2d173d99e606ac4f7f280b91) 0.1.5 +- [97bec36](https://github.com/gulpjs/gulp-cli/commit/97bec365ca8b2b5adb4bc68c3520ab652cbcc498) bump v8flags +- [#11](https://github.com/gulpjs/gulp-cli/pull/11) bump liftoff and v8flags (@tkellen) +- [b9e87f5](https://github.com/gulpjs/gulp-cli/commit/b9e87f51a0ad8fd3ae0d5753ef1bbf9613ea489c) bump liftoff and v8flags (@tkellen) + +### v0.1.4 (2015/01/10 20:17 +00:00) +- [895d905](https://github.com/gulpjs/gulp-cli/commit/895d9058596a09078989b7c1977281971554296f) 0.1.4 +- [6675cac](https://github.com/gulpjs/gulp-cli/commit/6675cac126bd969a70f40179a5cf2d41b1e2f765) add es6 support and tests - ref gulpjs/gulp#830 + +### v0.1.3 (2014/12/30 05:41 +00:00) +- [cc3c645](https://github.com/gulpjs/gulp-cli/commit/cc3c6456ab84e1d779d5f780840cf28489b07e15) 0.1.3 +- [181dd71](https://github.com/gulpjs/gulp-cli/commit/181dd71802ccbe7155ee7d204b6762daed3f54af) executable bin + +### v0.1.2 (2014/12/30 05:38 +00:00) +- [641e5c1](https://github.com/gulpjs/gulp-cli/commit/641e5c1779cbfce09193b296d2df45cae6496c7a) 0.1.2 +- [c1ac0e4](https://github.com/gulpjs/gulp-cli/commit/c1ac0e4c7bfa1f6b0abc7312f5a6d471a0386b8d) derp the bin env +- [f257820](https://github.com/gulpjs/gulp-cli/commit/f257820141ad16cab80a79fadb77dd326f3130bd) setup appveyor + +### v0.1.1 (2014/12/30 04:46 +00:00) +- [31acd4b](https://github.com/gulpjs/gulp-cli/commit/31acd4b919d9a5f88c9bbc637864893efe6842c1) 0.1.1 +- [a9ab2aa](https://github.com/gulpjs/gulp-cli/commit/a9ab2aa83c6c6937248765c590886e7f5b470d16) ship the bin +- [d5a3816](https://github.com/gulpjs/gulp-cli/commit/d5a3816f3e859baa338533f4fd9d2721328d6af1) fix test titles +- [6b2c2ef](https://github.com/gulpjs/gulp-cli/commit/6b2c2ef8827980af5f9c3b0b107173aa70c484ca) export a run function from index.js +- [#4](https://github.com/gulpjs/gulp-cli/pull/4) Fix windows tests (@heikki) +- [2d8c377](https://github.com/gulpjs/gulp-cli/commit/2d8c37736c114020a87c2e67198d68005006f9d3) convert windows path separators (@heikki) +- [1a1271a](https://github.com/gulpjs/gulp-cli/commit/1a1271ac0ff14bc98617e86ad4b6ccc72bec2065) fix windows line endings (@heikki) +- [9a11607](https://github.com/gulpjs/gulp-cli/commit/9a11607a0013d439af7ddbf216cb2f07d10dfdf0) fix stdout truncate problem on windows (@heikki) +- [7b1007e](https://github.com/gulpjs/gulp-cli/commit/7b1007e530519e68bf216b6c1723f6015c87ffef) add 'node' to exec command to fix windows issue (@heikki) +- [9c71562](https://github.com/gulpjs/gulp-cli/commit/9c71562792d68d81bc7ee3f6486db808f8f29df4) no need for marked-man in deps +- [29a5b52](https://github.com/gulpjs/gulp-cli/commit/29a5b52afbd279c4218688d3f21435f814570acf) cleanup devDeps and move marked-man to deps +- [194f667](https://github.com/gulpjs/gulp-cli/commit/194f66720892adfcf558380b6a5c65ab4613c13f) add task tree test from main module +- [5e8e7cf](https://github.com/gulpjs/gulp-cli/commit/5e8e7cfe904477424bdf0c08adb2c7251c44341f) add version test +- [b1b17e0](https://github.com/gulpjs/gulp-cli/commit/b1b17e0ef441e70b561a53c3283f82d05a801065) add flags test +- [80a4d87](https://github.com/gulpjs/gulp-cli/commit/80a4d87c5068337657607a20394a3b457ad49d01) add first CLI test +- [7061e68](https://github.com/gulpjs/gulp-cli/commit/7061e680b1f1a69187b96c7bc484864737cf00a1) update/prune deps +- [562823f](https://github.com/gulpjs/gulp-cli/commit/562823f4640b099965ebdcb0cf2fc46bc79c2627) add readme +- [bae9c61](https://github.com/gulpjs/gulp-cli/commit/bae9c61e35deea0358694a856a521f6e596238b7) being copying the CLI over diff --git a/LICENSE b/LICENSE index 6443cad0..9aedc0d7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015, 2017-2020, 2022-2023 Blaine Bublitz and Eric Schoffstall +Copyright (c) 2015 Blaine Bublitz, Eric Schoffstall and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index bfb6c6d1..f9fe6618 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,19 @@

- +

# gulp-cli -[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] +[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] Command Line Utility for Gulp -## Install - -```bash -npm install --global gulp-cli -``` - ## Usage ```bash -> gulp [flags] ... +> gulp [flags] tasks ``` ## Custom Metadata @@ -58,15 +52,7 @@ gulp.task(build); ## Tasks -The task(s) listed on the command line will be executed. -If more than one task is listed, Gulp will execute all of them -concurrently, that is, as if they had all been listed as dependencies of -a single task. - -By default, Gulp does not serialize tasks listed on the command line. If you would like to execute tasks serially, you must specify the `--series` flag. e.g. `gulp clean build --series` - -Just running `gulp` will execute the task `default`. If there is no -`default` task, gulp will error. +Tasks can be executed by running `gulp `. Just running `gulp` will execute the task you registered called `default`. If there is no `default` task, gulp will error. ## Completion > Thanks to the grunt team, specifically Tyler Kellen @@ -91,33 +77,23 @@ Add `gulp --completion=fish | source` to `~/.config/fish/config.fish`. ## Compilers -You can find a list of supported JavaScript variant languages in [Interpret][interpret-js-variants]. If you would like to add support for a new language, send pull requests/open issues on that project. +You can find a list of supported languages at https://github.com/js-cli/js-interpret. If you would like to add support for a new language, send pull requests/open issues on that project. ## Environment -The CLI adds `process.env.INIT_CWD` which is the original cwd it was launched from. +The CLI adds process.env.INIT_CWD which is the original cwd it was launched from. ## Configuration -Configuration is supported through the use of a `.gulp.*` file (e.g. `.gulp.js`, `.gulp.ts`). You can find a list of supported JavaScript variant languages in [Interpret][interpret-js-variants]. +Configuration is supported through the use of a `.gulp.*` file (e.g. `.gulp.json`, `.gulp.yml`). You can find a list of supported languages at https://github.com/js-cli/js-interpret. -A configuration file from the current working directory (`cwd`) or above are selected before a configuration file from the home directory (`~`). +Configuration from the home directory (`~`) and current working directory (`cwd`) are merged with `cwd` taking precedence. Supported configurations properties: -| Property | Description | -|--------------------|-------------| -| description | Top-level description of the project/gulpfile (Replaces "Tasks for ~/path/of/gulpfile.js") | -| gulpfile | Set a default gulpfile | -| preload | An array of modules to preload before running the gulpfile. Any relative paths will be resolved against the `--cwd` directory (if you don't want that behavior, use absolute paths) | -| nodeFlags | An array of flags used to forcibly respawn the process upon startup. For example, if you always want your gulpfiles to run in node's harmony mode, you can set `--harmony` here | -| flags.continue | Continue execution of tasks upon failure by default. | -| flags.compactTasks | Reduce the output of task dependency tree by default. | -| flags.tasksDepth | Set default depth of task dependency tree. | -| flags.silent | Silence logging by default | -| flags.series | Run tasks given on the CLI in series (the default is parallel) | -| message(data) | A function used to translate messages that pass through gulp-cli. Can receive an object like `{ tag: Symbol(), ...props }` where the `tag` is a symbol from `@gulpjs/messages`. The string returned from this function will be logged. If `false` is explicitly returned, no message will be logged. | -| timestamp(data) | A function used to provide timestamps for gulp-cli. Can receive an object like `{ tag: Symbol(), ...props }` where the `tag` is a symbol from `@gulpjs/messages`. The string returned from this function will be output before any messages. If `false` is explicitly returned, no timestamp will be output. | +| Property | Description | +|-------------|-------------| +| description | Top-level description of the project/gulpfile (Replaces "Tasks for ~/path/of/gulpfile.js") | ## Flags @@ -145,25 +121,35 @@ __Some flags only work with gulp 4 and will be ignored when invoked against gulp Print the global and local gulp versions. - --preload [path] + --require [path] - Will preload a module before running the gulpfile. This is useful for transpilers but also has other applications. + Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. --gulpfile [path] - -f + Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. --cwd [path] - Manually set the CWD. The search for the gulpfile, as well as the relativity of all preloads (with the `--preload` flag) will be from here. + Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. + + + --verify [path (optional)] + + Will verify plugins referenced in project's package.json against the plugins blacklist. --tasks -T Print the task dependency tree for the loaded gulpfile. + + --depth [number] + + Specify the depth of the task dependency tree to print. + --tasks-simple @@ -174,21 +160,6 @@ __Some flags only work with gulp 4 and will be ignored when invoked against gulp Print the task dependency tree, in JSON format, for the loaded gulpfile. The [path] argument is optional, and if given writes the JSON to the path. - - --tasks-depth [number] - - Specify the depth of the task dependency tree to print. This flag can be used with --tasks or --tasks-json. (This flag was named --depth before but is deprecated.) - - - --compact-tasks - - Reduce the output of task dependency tree by printing only top tasks and their child tasks. This flag can be used with --tasks or --tasks-json. - - - --sort-tasks - - Will sort top tasks of task dependency tree. This flag can be used with --tasks. - --color @@ -209,11 +180,6 @@ __Some flags only work with gulp 4 and will be ignored when invoked against gulp Continue execution of tasks upon failure. - - --series - - Run tasks given on the CLI in series (the default is parallel). - --log-level -L @@ -226,18 +192,21 @@ __Some flags only work with gulp 4 and will be ignored when invoked against gulp MIT - -[interpret-js-variants]: https://github.com/gulpjs/interpret#jsvariants - +[gittip-url]: https://www.gittip.com/WeAreFractal/ +[gittip-image]: http://img.shields.io/gittip/WeAreFractal.svg + +[downloads-image]: http://img.shields.io/npm/dm/gulp-cli.svg +[npm-url]: https://npmjs.org/package/gulp-cli +[npm-image]: http://img.shields.io/npm/v/gulp-cli.svg - -[downloads-image]: https://img.shields.io/npm/dm/gulp-cli.svg?style=flat-square -[npm-url]: https://www.npmjs.com/package/gulp-cli -[npm-image]: https://img.shields.io/npm/v/gulp-cli.svg?style=flat-square +[travis-url]: https://travis-ci.org/gulpjs/gulp-cli +[travis-image]: http://img.shields.io/travis/gulpjs/gulp-cli.svg?label=travis-ci -[ci-url]: https://github.com/gulpjs/gulp-cli/actions?query=workflow:dev -[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/gulp-cli/dev.yml?branch=master&style=flat-square +[appveyor-url]: https://ci.appveyor.com/project/gulpjs/gulp-cli +[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/gulp-cli.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulpjs/gulp-cli -[coveralls-image]: https://img.shields.io/coveralls/gulpjs/gulp-cli.svg?style=flat-square - +[coveralls-image]: http://img.shields.io/coveralls/gulpjs/gulp-cli/master.svg + +[gitter-url]: https://gitter.im/gulpjs/gulp +[gitter-image]: https://badges.gitter.im/gulpjs/gulp.png diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..9c5caa7c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,31 @@ +# http://www.appveyor.com/docs/appveyor-yml +# http://www.appveyor.com/docs/lang/nodejs-iojs + +branches: + # whitelist + only: + - master + +environment: + matrix: + # node.js + - nodejs_version: "0.10" + - nodejs_version: "0.12" + - nodejs_version: "4" + - nodejs_version: "6" + +install: + - npm -g install npm@latest + - set PATH=%APPDATA%\npm;%PATH% + - ps: Install-Product node $env:nodejs_version + - npm install + +test_script: + - node --version + - npm --version + - npm test + +build: off + +# build version format +version: "{build}" diff --git a/docs/CLI.md b/docs/CLI.md index 0b2bd592..c9bb2631 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -1,22 +1,14 @@ ### Usage -`gulp [flags] ...` +gulp [flags] tasks ### Tasks -The task(s) listed will be executed. -If more than one task is listed, Gulp will execute all of them -concurrently, that is, as if they had all been listed as dependencies of -a single task. - -By default, Gulp does not serialize tasks listed on the command line. If you would like to execute tasks serially, you must specify the `--series` flag. e.g. `gulp clean build --series` - -Just running `gulp` will execute the task `default`. If there is no -`default` task, gulp will error. +Tasks can be executed by running `gulp `. Just running `gulp` will execute the task you registered called `default`. If there is no `default` task, gulp will error. ### Compilers -You can find a list of supported languages at [https://github.com/gulpjs/interpret](https://github.com/gulpjs/interpret). If you would like to add support for a new language, send pull requests/open issues on that project. +You can find a list of supported languages at https://github.com/js-cli/js-interpret. If you would like to add support for a new language, send pull requests/open issues on that project. ### Environment @@ -37,12 +29,15 @@ gulp has very few flags to know about. All other flags are for tasks to use if n **--require** [path] Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. -**--gulpfile** [path], **-f** [path] +**--gulpfile** [path] Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. **--cwd** [path] Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. +**--verify** [path (optional)] + Will verify plugins referenced in project's package.json against the plugins blacklist. + **--tasks**, **-T** Print the task dependency tree for the loaded gulpfile. @@ -52,15 +47,6 @@ gulp has very few flags to know about. All other flags are for tasks to use if n **--tasks-json** [path] Print the task dependency tree, in JSON format, for the loaded gulpfile. The [path] argument is optional, and if given writes the JSON to the path. -**--tasks-depth** [number] - Specify the depth of the task dependency tree to print. This flag can be used with --tasks or --tasks-json. (This flag was named --depth before but is deprecated.) - -**--compact-tasks** - Reduce the output of task dependency tree by printing only top tasks and their child tasks. This flag can be used with --tasks or --tasks-json. - -**--sort-tasks** - Will sort top tasks of task dependency tree. This flag can be used with --tasks. - **--color** Will force gulp and gulp plugins to display colors, even when no color support is detected. @@ -73,8 +59,5 @@ gulp has very few flags to know about. All other flags are for tasks to use if n **--continue** Continue execution of tasks upon failure. -**--series** - Run tasks given on the CLI in series (the default is parallel). - **--log-level**, **-L** Set the loglevel. -L for least verbose and -LLLL for most verbose. -LLL is default. diff --git a/index.js b/index.js index 3491a7a6..6bb1f4eb 100644 --- a/index.js +++ b/index.js @@ -2,29 +2,30 @@ var fs = require('fs'); var path = require('path'); - var log = require('gulplog'); +var chalk = require('chalk'); var yargs = require('yargs'); var Liftoff = require('liftoff'); +var tildify = require('tildify'); var interpret = require('interpret'); var v8flags = require('v8flags'); -var messages = require('@gulpjs/messages'); +var merge = require('lodash.merge'); +var isString = require('lodash.isstring'); var findRange = require('semver-greatest-satisfied-range'); - var exit = require('./lib/shared/exit'); - -var arrayFind = require('./lib/shared/array-find'); -var makeTitle = require('./lib/shared/make-title'); -var makeHelp = require('./lib/shared/options/make-help'); -var cliOptions = require('./lib/shared/options/cli-options'); +var cliOptions = require('./lib/shared/cliOptions'); var completion = require('./lib/shared/completion'); +var verifyDeps = require('./lib/shared/verifyDependencies'); var cliVersion = require('./package.json').version; -var toConsole = require('./lib/shared/log/to-console'); -var mergeCliOpts = require('./lib/shared/config/cli-flags'); -var buildTranslations = require('./lib/shared/translate'); +var getBlacklist = require('./lib/shared/getBlacklist'); +var toConsole = require('./lib/shared/log/toConsole'); + +// Logging functions +var logVerify = require('./lib/shared/log/verify'); +var logBlacklistError = require('./lib/shared/log/blacklistError'); // Get supported ranges -var ranges = fs.readdirSync(path.join(__dirname, '/lib/versioned/')); +var ranges = fs.readdirSync(__dirname + '/lib/versioned/'); // Set env var for ORIGINAL cwd // before anything touches it @@ -32,181 +33,119 @@ process.env.INIT_CWD = process.cwd(); var cli = new Liftoff({ name: 'gulp', - processTitle: makeTitle('gulp', process.argv.slice(2)), + completions: completion, extensions: interpret.jsVariants, v8flags: v8flags, - configFiles: [ - { - name: '.gulp', - path: '.', - extensions: interpret.jsVariants, - findUp: true, - }, - { - name: '.gulp', - path: '~', - extensions: interpret.jsVariants, + configFiles: { + '.gulp': { + home: { + path: '~', + extensions: interpret.extensions, + }, + cwd: { + path: '.', + extensions: interpret.extensions, + }, }, - ], + }, }); -var parser = yargs - .help(false) - .version(false) - .detectLocale(false) - .showHelpOnFail(false) - .exitProcess(false) - .fail(onFail) - .options(cliOptions); +var usage = + '\n' + chalk.bold('Usage:') + + ' gulp ' + chalk.blue('[options]') + ' tasks'; -var opts = parser.parse(); +var parser = yargs.usage(usage, cliOptions); +var opts = parser.argv; -// Set up event listeners for logging temporarily. -// TODO: Rework console logging before we can set up proper config -// Possibly by batching messages in gulplog until listeners are attached -var cleanupListeners = toConsole(log, opts, buildTranslations()); - -cli.on('preload:before', function(name) { - log.info({ tag: messages.PRELOAD_BEFORE, name: name }); -}); - -cli.on('preload:success', function(name) { - log.info({ tag: messages.PRELOAD_SUCCESS, name: name }); -}); +// This translates the --continue flag in gulp +// To the settle env variable for undertaker +// We use the process.env so the user's gulpfile +// Can know about the flag +if (opts.continue) { + process.env.UNDERTAKER_SETTLE = 'true'; +} -cli.on('preload:failure', function(name, error) { - log.warn({ tag: messages.PRELOAD_FAILURE, name: name }); - if (error) { - log.warn({ tag: messages.PRELOAD_ERROR, error: error }); - } -}); +// Set up event listeners for logging. +toConsole(log, opts); -cli.on('loader:success', function(name) { - // This is needed because interpret needs to stub the .mjs extension - // Without the .mjs require hook, rechoir blows up - // However, we don't want to show the mjs-stub loader in the logs - /* istanbul ignore else */ - if (path.basename(name, '.js') !== 'mjs-stub') { - log.info({ tag: messages.LOADER_SUCCESS, name: name }); - } +cli.on('require', function(name) { + log.info('Requiring external module', chalk.magenta(name)); }); -cli.on('loader:failure', function(name, error) { - log.warn({ tag: messages.LOADER_FAILURE, name: name }); - if (error) { - log.warn({ tag: messages.LOADER_ERROR, error: error }); - } +cli.on('requireFail', function(name) { + log.error(chalk.red('Failed to load external module'), chalk.magenta(name)); }); cli.on('respawn', function(flags, child) { - log.info({ tag: messages.NODE_FLAGS, flags: flags }); - log.info({ tag: messages.RESPAWNED, pid: child.pid }); + var nodeFlags = chalk.magenta(flags.join(', ')); + var pid = chalk.magenta(child.pid); + log.info('Node flags detected:', nodeFlags); + log.info('Respawned to PID:', pid); }); function run() { - cli.prepare({ + cli.launch({ cwd: opts.cwd, configPath: opts.gulpfile, - preload: opts.preload, - }, onPrepare); + require: opts.require, + completion: opts.completion, + }, handleArguments); } module.exports = run; -function isDefined(cfg) { - return cfg != null; -} - -function onFail(message, error) { - // Run Liftoff#prepare to get the env. Primarily to load themes. - cli.prepare({}, function (env) { - // We only use the first config found, which is a departure from - // the previous implementation that merged with the home - var cfg = arrayFind(env.config, isDefined); - var translate = buildTranslations(cfg); - - var errorMsg = translate.message({ tag: messages.ARGV_ERROR, message: message, error: error }); - if (errorMsg) { - console.error(errorMsg); - } +// The actual logic +function handleArguments(env) { - makeHelp(parser, translate).showHelp(console.error); - exit(1); + // Map an array of keys to preserve order + var configFilePaths = ['home', 'cwd'].map(function(key) { + return env.configFiles['.gulp'][key]; }); -} - -function onPrepare(env) { - // We only use the first config found, which is a departure from - // the previous implementation that merged with the home - var cfg = arrayFind(env.config, isDefined); - var flags = mergeCliOpts(opts, cfg); - - // Remove the previous listeners since we have appropriate config now - cleanupListeners(); - - var translate = buildTranslations(cfg); - - // Set up event listeners for logging again after configuring. - toConsole(log, flags, translate); - - cli.execute(env, cfg.nodeFlags, function (env) { - onExecute(env, flags, translate); + configFilePaths.filter(isString).forEach(function(filePath) { + merge(opts, require(filePath)); }); -} -// The actual logic -function onExecute(env, flags, translate) { - // Moved the completion logic outside of Liftoff since we need to include translations - if (flags.completion) { - return completion(flags.completion, translate); - } - - // This translates the --continue flag in gulp - // To the settle env variable for undertaker - // We use the process.env so the user's gulpfile - // Can know about the flag - if (flags.continue) { - process.env.UNDERTAKER_SETTLE = 'true'; + if (opts.help) { + console.log(parser.help()); + exit(0); } - if (flags.help) { - makeHelp(parser, translate).showHelp(console.log); + if (opts.version) { + log.info('CLI version', cliVersion); + if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') { + log.info('Local version', env.modulePackage.version); + } exit(0); } - // Anything that needs to print outside of the logging mechanism should use console.log - if (flags.version) { - console.log('CLI version:', cliVersion); - console.log('Local version:', env.modulePackage.version || 'Unknown'); - exit(0); + if (opts.verify) { + var pkgPath = opts.verify !== true ? opts.verify : 'package.json'; + if (path.resolve(pkgPath) !== path.normalize(pkgPath)) { + pkgPath = path.join(env.cwd, pkgPath); + } + log.info('Verifying plugins in ' + pkgPath); + return getBlacklist(function(err, blacklist) { + if (err) { + return logBlacklistError(err); + } + + var blacklisted = verifyDeps(require(pkgPath), blacklist); + + logVerify(blacklisted); + }); } if (!env.modulePath) { - var missingNodeModules = - fs.existsSync(path.join(env.cwd, 'package.json')) - && !fs.existsSync(path.join(env.cwd, 'node_modules')); - - var hasYarn = fs.existsSync(path.join(env.cwd, 'yarn.lock')); - if (missingNodeModules) { - log.error({ tag: messages.MISSING_NODE_MODULES, cwd: env.cwd }); - if (hasYarn) { - log.error({ tag: messages.YARN_INSTALL }) - } else { - log.error({ tag: messages.NPM_INSTALL }) - } - } else { - log.error({ tag: messages.MISSING_GULP, cwd: env.cwd }); - if (hasYarn) { - log.error({ tag: messages.YARN_INSTALL_GULP }); - } else { - log.error({ tag: messages.NPM_INSTALL_GULP }); - } - } + log.error( + chalk.red('Local gulp not found in'), + chalk.magenta(tildify(env.cwd)) + ); + log.error(chalk.red('Try running: npm install gulp')); exit(1); } if (!env.configPath) { - log.error({ tag: messages.MISSING_GULPFILE }); + log.error(chalk.red('No gulpfile found')); exit(1); } @@ -214,18 +153,21 @@ function onExecute(env, flags, translate) { // we let them chdir as needed if (process.cwd() !== env.cwd) { process.chdir(env.cwd); - log.info({ tag: messages.CWD_CHANGED, cwd: env.cwd }); + log.info( + 'Working directory changed to', + chalk.magenta(tildify(env.cwd)) + ); } // Find the correct CLI version to run var range = findRange(env.modulePackage.version, ranges); if (!range) { - log.error({ tag: messages.UNSUPPORTED_GULP_VERSION, version: env.modulePackage.version }); - exit(1); + return log.error( + chalk.red('Unsupported gulp version', env.modulePackage.version) + ); } // Load and execute the CLI version - var versionedDir = path.join(__dirname, '/lib/versioned/', range, '/'); - require(versionedDir)(env, flags, translate); + require(path.join(__dirname, '/lib/versioned/', range, '/'))(opts, env); } diff --git a/lib/shared/array-find.js b/lib/shared/array-find.js deleted file mode 100644 index 0596268c..00000000 --- a/lib/shared/array-find.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -function arrayFind(arr, fn) { - if (!Array.isArray(arr)) { - return; - } - - var idx = 0; - while (idx < arr.length) { - var result = fn(arr[idx]); - if (result) { - // TODO: This is wrong in Liftoff - return arr[idx]; - } - idx++; - } -} - -module.exports = arrayFind; diff --git a/lib/shared/cliOptions.js b/lib/shared/cliOptions.js new file mode 100644 index 00000000..d3aa9c4c --- /dev/null +++ b/lib/shared/cliOptions.js @@ -0,0 +1,98 @@ +'use strict'; + +var chalk = require('chalk'); + +module.exports = { + help: { + alias: 'h', + type: 'boolean', + desc: chalk.gray( + 'Show this help.'), + }, + version: { + alias: 'v', + type: 'boolean', + desc: chalk.gray( + 'Print the global and local gulp versions.'), + }, + require: { + type: 'string', + requiresArg: true, + desc: chalk.gray( + 'Will require a module before running the gulpfile. ' + + 'This is useful for transpilers but also has other applications.'), + }, + gulpfile: { + type: 'string', + requiresArg: true, + desc: chalk.gray( + 'Manually set path of gulpfile. Useful if you have multiple gulpfiles. ' + + 'This will set the CWD to the gulpfile directory as well.'), + }, + cwd: { + type: 'string', + requiresArg: true, + desc: chalk.gray( + 'Manually set the CWD. The search for the gulpfile, ' + + 'as well as the relativity of all requires will be from here.'), + }, + verify: { + desc: chalk.gray( + 'Will verify plugins referenced in project\'s package.json against ' + + 'the plugins blacklist.'), + }, + tasks: { + alias: 'T', + type: 'boolean', + desc: chalk.gray( + 'Print the task dependency tree for the loaded gulpfile.'), + }, + depth: { + type: 'number', + requiresArg: true, + desc: chalk.gray( + 'Specify the depth of the task dependency tree.'), + }, + 'tasks-simple': { + type: 'boolean', + desc: chalk.gray( + 'Print a plaintext list of tasks for the loaded gulpfile.'), + }, + 'tasks-json': { + desc: chalk.gray( + 'Print the task dependency tree, ' + + 'in JSON format, for the loaded gulpfile.'), + }, + color: { + type: 'boolean', + desc: chalk.gray( + 'Will force gulp and gulp plugins to display colors, ' + + 'even when no color support is detected.'), + }, + 'no-color': { + type: 'boolean', + desc: chalk.gray( + 'Will force gulp and gulp plugins to not display colors, ' + + 'even when color support is detected.'), + }, + silent: { + alias: 'S', + type: 'boolean', + desc: chalk.gray( + 'Suppress all gulp logging.'), + }, + continue: { + type: 'boolean', + desc: chalk.gray( + 'Continue execution of tasks upon failure.'), + }, + 'log-level': { + alias: 'L', + // Type isn't needed because count acts as a boolean + count: true, + // Can't use `default` because it seems to be off by one + desc: chalk.gray( + 'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' + + '-LLL is default.'), + }, +}; diff --git a/lib/shared/completion.js b/lib/shared/completion.js index d637d140..3a47023d 100644 --- a/lib/shared/completion.js +++ b/lib/shared/completion.js @@ -3,18 +3,20 @@ var fs = require('fs'); var path = require('path'); -var messages = require('@gulpjs/messages'); - -module.exports = function(name, translate) { +module.exports = function(name) { if (typeof name !== 'string') { - throw new Error(translate.message({ tag: messages.COMPLETION_TYPE_MISSING })); + throw new Error('Missing completion type'); } var file = path.join(__dirname, '../../completion', name); try { console.log(fs.readFileSync(file, 'utf8')); process.exit(0); } catch (err) { - console.log(translate.message({ tag: messages.COMPLETION_TYPE_UNKNOWN, name: name })); + console.log( + 'echo "gulp autocompletion rules for', + '\'' + name + '\'', + 'not found"' + ); process.exit(5); } }; diff --git a/lib/shared/config/cli-flags.js b/lib/shared/config/cli-flags.js deleted file mode 100644 index 996aaa6b..00000000 --- a/lib/shared/config/cli-flags.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -var copyProps = require('copy-props'); - -var fromConfigToCliOpts = { - 'flags.silent': 'silent', - 'flags.continue': 'continue', - 'flags.series': 'series', - 'flags.logLevel': 'logLevel', - 'flags.compactTasks': 'compactTasks', - 'flags.tasksDepth': 'tasksDepth', - 'flags.sortTasks': 'sortTasks', -}; - -function mergeCliOpts(opts, config) { - opts = copyProps(opts, {}); - return copyProps(config, opts, fromConfigToCliOpts, defaults); -} - -function defaults(cfgInfo, optInfo) { - if (optInfo.value === undefined) { - return cfgInfo.value; - } -} - -module.exports = mergeCliOpts; diff --git a/lib/shared/exit.js b/lib/shared/exit.js index 9d619c32..0591e1ed 100644 --- a/lib/shared/exit.js +++ b/lib/shared/exit.js @@ -2,7 +2,6 @@ // Fix stdout truncation on windows function exit(code) { - /* istanbul ignore next */ if (process.platform === 'win32' && process.stdout.bufferSize) { process.stdout.once('drain', function() { process.exit(code); diff --git a/lib/shared/getBlacklist.js b/lib/shared/getBlacklist.js new file mode 100644 index 00000000..f7e0557e --- /dev/null +++ b/lib/shared/getBlacklist.js @@ -0,0 +1,17 @@ +'use strict'; + +var wreck = require('wreck'); + +var url = 'http://gulpjs.com/plugins/blackList.json'; + +function getBlacklist(cb) { + wreck.get(url, { json: true }, function(err, res, blacklist) { + if (err) { + return cb(err); + } + + cb(null, blacklist); + }); +} + +module.exports = getBlacklist; diff --git a/lib/shared/is-object.js b/lib/shared/is-object.js deleted file mode 100644 index 6375b561..00000000 --- a/lib/shared/is-object.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -function isObject(v) { - return (v != null && typeof v === 'object' && !Array.isArray(v)); -} - -module.exports = isObject; diff --git a/lib/shared/log/blacklistError.js b/lib/shared/log/blacklistError.js new file mode 100644 index 00000000..c3c5bf32 --- /dev/null +++ b/lib/shared/log/blacklistError.js @@ -0,0 +1,14 @@ +'use strict'; + +var chalk = require('chalk'); +var log = require('gulplog'); + +var exit = require('../exit'); + +function logBlacklistError(err) { + log.error(chalk.red('Error: failed to retrieve plugins black-list')); + log.error(err.message); // Avoid duplicating for each version + exit(1); +} + +module.exports = logBlacklistError; diff --git a/lib/shared/log/copy-tree.js b/lib/shared/log/copy-tree.js deleted file mode 100644 index 99d7b5fa..00000000 --- a/lib/shared/log/copy-tree.js +++ /dev/null @@ -1,81 +0,0 @@ -'use strict'; - -function copyNode(node) { - var newNode = {}; - Object.keys(node).forEach(function(key) { - newNode[key] = node[key]; - }); - return newNode; -} - -var defaultNodeFactory = { - topNode: copyNode, - taskNode: copyNode, - childNode: copyNode, -}; - -function copyTree(tree, opts, nodeFactory) { - opts = opts || {}; - - var depth = opts.tasksDepth; - depth = typeof depth === 'number' ? ((depth < 1) ? 1 : depth) : null; - - nodeFactory = nodeFactory || defaultNodeFactory; - - var newTree = nodeFactory.topNode(tree); - newTree.nodes = []; - - if (Array.isArray(tree.nodes)) { - tree.nodes.forEach(visit); - } - - function visit(node) { - var newNode = nodeFactory.taskNode(node); - newNode.nodes = []; - newTree.nodes.push(newNode); - - if (opts.compactTasks) { - forEach(node.nodes, copyNotRecursively, newNode); - - } else if (!depth || depth > 1) { - forEach(node.nodes, copyRecursively, depth, 2, newNode); - } - } - - function copyNotRecursively(child, newParent) { - var newChild = nodeFactory.childNode(child); - newChild.nodes = []; - newParent.nodes.push(newChild); - - if (child.branch) { - forEach(child.nodes, copyNotRecursively, newChild); - } - } - - function copyRecursively(child, maxDepth, nowDepth, newParent) { - var newChild = nodeFactory.childNode(child); - newChild.nodes = []; - newParent.nodes.push(newChild); - - if (!maxDepth || maxDepth > nowDepth) { - forEach(child.nodes, copyRecursively, maxDepth, nowDepth + 1, newChild); - } - } - - return newTree; -} - -function forEach(nodes, fn) { - if (!Array.isArray(nodes)) { - return; - } - - var args = Array.prototype.slice.call(arguments, 2); - - for (var i = 0, n = nodes.length; i < n; i++) { - fn.apply(nodes[i], [nodes[i]].concat(args)); - } -} - -module.exports = copyTree; - diff --git a/lib/shared/log/format-hrtime.js b/lib/shared/log/format-hrtime.js deleted file mode 100644 index 0547bd1e..00000000 --- a/lib/shared/log/format-hrtime.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -var units = [ - [ 'h', 3600e9 ], - [ 'min', 60e9 ], - [ 's', 1e9 ], - [ 'ms', 1e6 ], - [ 'μs', 1e3 ], -]; - -function formatHrTime(hrtime) { - if (!Array.isArray(hrtime) || hrtime.length !== 2) { - return ''; - } - if (typeof hrtime[0] !== 'number' || typeof hrtime[1] !== 'number') { - return ''; - } - - var nano = hrtime[0] * 1e9 + hrtime[1]; - - for (var i = 0; i < units.length; i++) { - if (nano < units[i][1]) { - continue; - } - - if (nano >= units[i][1] * 10) { - return Math.round(nano / units[i][1]) + ' ' + units[i][0]; - } - - var s = String(Math.round(nano * 1e2 / units[i][1])); - if (s.slice(-2) === '00') { - s = s.slice(0, -2); - } else if (s.slice(-1) === '0') { - s = s.slice(0, -2) + '.' + s.slice(-2, -1); - } else { - s = s.slice(0, -2) + '.' + s.slice(-2); - } - return s + ' ' + units[i][0]; - } - - if (nano > 0) { - return nano + ' ns'; - } - - return ''; -} - -module.exports = formatHrTime; diff --git a/lib/shared/log/tasks.js b/lib/shared/log/tasks.js index 0590ef4a..7d311fe3 100644 --- a/lib/shared/log/tasks.js +++ b/lib/shared/log/tasks.js @@ -1,170 +1,183 @@ 'use strict'; -var stringWidth = require('string-width'); -var messages = require('@gulpjs/messages'); +var archy = require('archy'); +var chalk = require('chalk'); +var log = require('gulplog'); -var isObject = require('../is-object'); +var sortBy = require('lodash.sortby'); +var isString = require('lodash.isstring'); +var isObject = require('lodash.isplainobject'); -function logTasks(tree, opts, getTask, translate) { - if (opts.sortTasks) { - tree.nodes = tree.nodes.sort(compareByLabel); - } - - var maxDepth = opts.tasksDepth; - if (typeof maxDepth !== 'number') { - maxDepth = 50; - } else if (maxDepth < 1) { - maxDepth = 1; - } +function logTasks(tree, depth, getTask) { + depth = (typeof depth !== 'number') ? null : ((depth < 1) ? 1 : depth); - var compactedTasks = opts.compactTasks ? tree.nodes : []; + var lineInfos = []; + var entryObserver = getLineInfoCollector(lineInfos); - var treeOpts = { - maxDepth: maxDepth, - compactedTasks: compactedTasks, - getTask: getTask, - }; - - printTaskTree(tree, treeOpts); + tree = copyTree(tree, depth, getTask, entryObserver); - function printTaskTree(tree, opts) { - var lines = []; - lines.push({ label: tree.label }); - var maxLabelWidth = 0; + var spacer = getSpacerForLineIndents(tree, lineInfos); + var lines = getLinesContainingOnlyBranches(tree); - tree.nodes.forEach(function(node, idx, arr) { - var isLast = idx === arr.length - 1; - var w = createTreeLines(node, lines, opts, 1, '', isLast); - maxLabelWidth = Math.max(maxLabelWidth, w); - }); + log.info(tree.label); + printTreeList(lines, spacer, lineInfos); +} - lines.forEach(function(line) { - var s = line.label; - if (line.desc) { - var spaces = ' '.repeat(maxLabelWidth - line.width) + ' '; - s += spaces + line.desc; - } - if (s) { - // We don't need timestamps here - console.log(s); - } - }); - } +function getLineInfoCollector(lineInfos) { + return { + topTask: function(node) { + lineInfos.push({ + name: node.label, + desc: node.desc, + type: 'top', + }); + }, + option: function(opt) { + lineInfos.push({ + name: opt.label, + desc: opt.desc, + type: 'option', + }); + }, + childTask: function(node) { + lineInfos.push({ + name: node.label, + type: 'child', + }); + }, + }; +} - function createTreeLines(node, lines, opts, depth, bars, isLast) { - var task = { label: node.label, bars: bars, depth: depth }; - if (depth === 1) { - var t = opts.getTask(node.label); - task.desc = t.description; - task.flags = t.flags; - } +function copyTree(tree, depth, getTask, entryObserver) { + var newTree = { + label: tree.label, + nodes: [], + }; - var isLeaf = isLeafNode(node, depth, opts); + sortBy(tree.nodes, sorter).forEach(visit); - var maxLabelWidth = addTaskToLines(task, lines, isLast, isLeaf); + function sorter(node) { + return node.label; + } - if (!isLeaf) { - bars += (isLast ? ' ' : translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL })); - bars += ' ' - node.nodes.forEach(function(node, idx, arr) { - var isLast = idx === arr.length - 1; - createTreeLines(node, lines, opts, depth + 1, bars, isLast); + function visit(node) { + var task = getTask(node.label) || {}; + + var newNode = { + label: node.label, + desc: isString(task.description) ? task.description : '', + opts: [], + nodes: [], + }; + entryObserver.topTask(newNode); + newTree.nodes.push(newNode); + + if (isObject(task.flags)) { + Object.keys(task.flags).sort().forEach(function(flag) { + if (flag.length === 0) { + return; + } + var opt = { + label: flag, + desc: isString(task.flags[flag]) ? task.flags[flag] : '', + }; + entryObserver.option(opt); + newNode.opts.push(opt); + newNode.label += '\n' + opt.label; // The way of archy for options. }); } - return maxLabelWidth; + if (!depth || depth > 1) { + var fn = function(child, maxDepth, nowDepth, newParent) { + var newChild = { + label: child.label, + nodes: [], + }; + entryObserver.childTask(newChild); + newChild.label = ''; // Because don't use child tasks to calc indents. + newParent.nodes.push(newChild); + if (!maxDepth || maxDepth > nowDepth) { + forEachNode(child.nodes, fn, maxDepth, nowDepth + 1, newChild); + } + }; + forEachNode(node.nodes, fn, depth, 2, newNode); + } } - function addTaskToLines(task, lines, isLast, isLeaf) { - var taskBars = task.bars + (isLast - ? translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_UP_AND_RIGHT }) - : translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL_AND_RIGHT })) + - translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_HORIZONTAL }); - if (isLeaf) { - taskBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_HORIZONTAL }); - } else { - taskBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_DOWN_AND_HORIZONTAL }); - } - taskBars += ' '; + return newTree; +} - var line = {}; - if (task.depth === 1) { - line.label = taskBars + translate.message({ tag: messages.TASK_NAME, name: task.label }); - } else { - line.label = taskBars + translate.message({ tag: messages.TASK_NAME, name: task.label }); - } - line.width = stringWidth(line.label); +function forEachNode(nodes, fn) { + if (!Array.isArray(nodes)) { + return; + } - if (typeof task.desc === 'string' && task.desc) { - line.desc = translate.message({ tag: messages.TASK_DESCRIPTION, description: task.desc }); - } - lines.push(line); + var args = [].slice.call(arguments, 2); - var maxLabelWidth = line.width; + for (var i = 0, n = nodes.length; i < n; i++) { + fn.apply(nodes[i], [nodes[i]].concat(args)); + } +} - if (!isObject(task.flags)) { - return maxLabelWidth; - } +function getSpacerForLineIndents(tree, lineInfos) { + var maxSize = 0; + var sizes = []; + + archy(tree) + .split('\n') + .slice(1, -1) + .forEach(function(line, index) { + var info = lineInfos[index]; + if (info.type === 'top' || info.type === 'option') { + maxSize = Math.max(maxSize, line.length); + sizes.push(line.length); + } else { + sizes.push(0); + } + }); - var flagBars = task.bars; - if (isLast) { - flagBars += ' '; - } else { - flagBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL }); - } - flagBars += ' '; + maxSize += 3; - if (isLeaf) { - flagBars += ' '; - } else { - flagBars += translate.message({ tag: messages.BOX_DRAWINGS_LIGHT_VERTICAL }); - } - flagBars += ' '; + return function(index) { + return Array(maxSize - sizes[index]).join(' '); + }; +} - Object.entries(task.flags).sort(flagSorter).forEach(addFlagsToLines); +function getLinesContainingOnlyBranches(tree) { + tree.nodes.forEach(function(node) { + node.label = ''; + node.opts.forEach(function() { + node.label += '\n'; + }); + }); - function addFlagsToLines(ent) { - if (typeof ent[0] !== 'string' || !ent[0]) return; - var line = {}; - line.label = flagBars + translate.message({ tag: messages.TASK_FLAG, flag: ent[0] }); - line.width = stringWidth(line.label); + return archy(tree) + .split('\n') + .slice(1, -1); +} - maxLabelWidth = Math.max(maxLabelWidth, line.width); +function printTreeList(lines, spacer, lineInfos) { + lines.forEach(function(branch, index) { + var info = lineInfos[index]; - if (typeof ent[1] === 'string' && ent[1] !== '') { - line.desc = translate.message({ tag: messages.TASK_FLAG_DESCRIPTION, description: ent[1] }); + var line = chalk.white(branch); + + if (info.type === 'top') { + line += chalk.cyan(info.name); + if (info.desc.length > 0) { + line += spacer(index) + chalk.white(info.desc); + } + } else if (info.type === 'option') { + line += chalk.magenta(info.name); + if (info.desc.length > 0) { + line += spacer(index) + chalk.white('…' + info.desc); } - lines.push(line); + } else { // If (info.type === 'child') { + line += chalk.white(info.name); } - return maxLabelWidth; - } -} - -function isLeafNode(node, depth, opts) { - if (depth >= opts.maxDepth) { - return true; - } else if (depth > 1 && opts.compactedTasks.includes(node)) { - return true; - } else if (!Array.isArray(node.nodes) || node.nodes.length === 0) { - return true; - } - return false; -} - -function compareByLabel(a, b) { - /* istanbul ignore if */ - if (!b.label) { - return -1; - } else /* istanbul ignore if */ if (!a.label) { - return 1; - } else { - return (a.label <= b.label) ? -1 : 1; - } -} - -function flagSorter(a, b) { - return (a[0] <= b[0]) ? -1 : 1; + log.info(line); + }); } module.exports = logTasks; diff --git a/lib/shared/log/to-console.js b/lib/shared/log/to-console.js deleted file mode 100644 index 3cdf1ca2..00000000 --- a/lib/shared/log/to-console.js +++ /dev/null @@ -1,135 +0,0 @@ -'use strict'; - -var messages = require('@gulpjs/messages'); - -/* istanbul ignore next */ -function noop() {} - -function toConsole(log, opts, translate) { - // Return immediately if logging is - // not desired. - if (opts.tasksSimple || opts.tasksJson || opts.help || opts.version || opts.silent) { - // Keep from crashing process when silent. - log.on('error', noop); - return function () { - log.removeListener('error', noop); - }; - } - - // Default loglevel to info level (3). - var loglevel = opts.logLevel || 3; - - var deprecatedPrinted = false; - log.on('deprecated', onDeprecated); - - // -L: Logs error events. - if (loglevel > 0) { - log.on('error', onError); - } - - // -LL: Logs warn and error events. - if (loglevel > 1) { - log.on('warn', onWarn); - } - - // -LLL: Logs info, warn and error events. - if (loglevel > 2) { - log.on('info', onInfo); - } - - if (loglevel > 3) { - log.on('debug', onDebug); - } - - return function () { - log.removeListener('deprecated', onDeprecated); - log.removeListener('error', onError); - log.removeListener('warn', onWarn); - log.removeListener('info', onInfo); - log.removeListener('debug', onDebug); - }; - - function onDeprecated() { - if (!deprecatedPrinted) { - var msg = { tag: messages.GULPLOG_DEPRECATED }; - // Get message and timestamp before printing anything to avoid - // logging a half message if there's an error in one of them - var message = translate.message(msg); - var timestamp = translate.timestamp(msg); - - if (message) { - // Ensure timestamp is not written without a message - if (timestamp) { - process.stderr.write(timestamp + ' '); - } - console.error(message); - } - - deprecatedPrinted = true; - } - } - - function onError(msg) { - // Get message and timestamp before printing anything to avoid - // logging a half message if there's an error in one of them - var message = translate.message(msg); - var timestamp = translate.timestamp(msg); - - if (message) { - // Ensure timestamp is not written without a message - if (timestamp) { - process.stderr.write(timestamp + ' '); - } - console.error(message); - } - } - - // onWarn, onInfo, and onDebug are currently all the same - // implementation but separated to change independently - function onWarn(msg) { - // Get message and timestamp before printing anything to avoid - // logging a half message if there's an error in one of them - var message = translate.message(msg); - var timestamp = translate.timestamp(msg); - - if (message) { - // Ensure timestamp is not written without a message - if (timestamp) { - process.stdout.write(timestamp + ' '); - } - console.log(message); - } - } - - function onInfo(msg) { - // Get message and timestamp before printing anything to avoid - // logging a half message if there's an error in one of them - var message = translate.message(msg); - var timestamp = translate.timestamp(msg); - - if (message) { - // Ensure timestamp is not written without a message - if (timestamp) { - process.stdout.write(timestamp + ' '); - } - console.log(message); - } - } - - function onDebug(msg) { - // Get message and timestamp before printing anything to avoid - // logging a half message if there's an error in one of them - var message = translate.message(msg); - var timestamp = translate.timestamp(msg); - - if (message) { - // Ensure timestamp is not written without a message - if (timestamp) { - process.stdout.write(timestamp + ' '); - } - console.log(message); - } - } -} - -module.exports = toConsole; diff --git a/lib/shared/log/toConsole.js b/lib/shared/log/toConsole.js new file mode 100644 index 00000000..39483bd6 --- /dev/null +++ b/lib/shared/log/toConsole.js @@ -0,0 +1,41 @@ +'use strict'; + +var fancyLog = require('fancy-log'); + +function noop() {} + +// The sorting of the levels is +// significant. +var levels = [ + 'error', // -L: Logs error events. + 'warn', // -LL: Logs warn and error events. + 'info', // -LLL: Logs info, warn and error events. + 'debug', // -LLLL: Logs all log levels. +]; + +function toConsole(log, opts) { + // Return immediately if logging is + // not desired. + if (opts.tasksSimple || opts.silent) { + // Keep from crashing process when silent. + log.on('error', noop); + return; + } + + // Default loglevel to info level (3). + var loglevel = opts.logLevel || 3; + + levels + .filter(function(item, i) { + return i < loglevel; + }) + .forEach(function(level) { + if (level === 'error') { + log.on(level, fancyLog.error); + } else { + log.on(level, fancyLog); + } + }); +} + +module.exports = toConsole; diff --git a/lib/shared/log/verify.js b/lib/shared/log/verify.js new file mode 100644 index 00000000..795867a7 --- /dev/null +++ b/lib/shared/log/verify.js @@ -0,0 +1,28 @@ +'use strict'; + +var chalk = require('chalk'); +var log = require('gulplog'); + +var exit = require('../exit'); + +function logVerify(blacklisted) { + var pluginNames = Object.keys(blacklisted); + + if (!pluginNames.length) { + log.info( + chalk.green('There are no blacklisted plugins in this project') + ); + exit(0); + } + + log.warn(chalk.red('Blacklisted plugins found in this project:')); + + pluginNames.map(function(pluginName) { + var reason = blacklisted[pluginName]; + log.warn(chalk.bgRed(pluginName) + ': ' + reason); + }); + + exit(1); +} + +module.exports = logVerify; diff --git a/lib/shared/make-title.js b/lib/shared/make-title.js deleted file mode 100644 index aa6d2ee3..00000000 --- a/lib/shared/make-title.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -function makeTitle(cmd, argv) { - if (!argv || argv.length === 0) { - return cmd; - } - - return [cmd].concat(argv).join(' '); -} - -module.exports = makeTitle; diff --git a/lib/shared/options/cli-options.js b/lib/shared/options/cli-options.js deleted file mode 100644 index b84c7948..00000000 --- a/lib/shared/options/cli-options.js +++ /dev/null @@ -1,94 +0,0 @@ -'use strict'; - -var messages = require('@gulpjs/messages'); - -var options = { - help: { - alias: 'h', - type: 'boolean', - tag: messages.FLAG_HELP, - }, - version: { - alias: 'v', - type: 'boolean', - tag: messages.FLAG_VERSION, - }, - preload: { - type: 'string', - requiresArg: true, - tag: messages.FLAG_PRELOAD, - }, - gulpfile: { - alias: 'f', - type: 'string', - requiresArg: true, - tag: messages.FLAG_GULPFILE, - }, - cwd: { - type: 'string', - requiresArg: true, - tag: messages.FLAG_CWD, - }, - tasks: { - alias: 'T', - type: 'boolean', - tag: messages.FLAG_TASKS, - }, - 'tasks-simple': { - type: 'boolean', - tag: messages.FLAG_TASKS_SIMPLE, - }, - 'tasks-json': { - tag: messages.FLAG_TASKS_JSON, - }, - 'tasks-depth': { - alias: 'depth', - type: 'number', - requiresArg: true, - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_TASKS_DEPTH, - }, - 'compact-tasks': { - type: 'boolean', - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_COMPACT_TASKS, - }, - 'sort-tasks': { - type: 'boolean', - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_SORT_TASKS, - }, - color: { - type: 'boolean', - tag: messages.FLAG_COLOR, - }, - 'no-color': { - type: 'boolean', - tag: messages.FLAG_NO_COLOR, - }, - silent: { - alias: 'S', - type: 'boolean', - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_SILENT, - }, - continue: { - type: 'boolean', - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_CONTINUE, - }, - series: { - type: 'boolean', - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_SERIES, - }, - 'log-level': { - alias: 'L', - // Type isn't needed because count acts as a boolean - count: true, - default: undefined, // To detect if this cli option is specified. - tag: messages.FLAG_LOG_LEVEL, - } -}; - -module.exports = options; diff --git a/lib/shared/options/make-help.js b/lib/shared/options/make-help.js deleted file mode 100644 index 7a56387f..00000000 --- a/lib/shared/options/make-help.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var cliOptions = require('./cli-options'); - -var messages = require('@gulpjs/messages'); - -function makeHelp(parser, translate) { - var usage = translate.message({ tag: messages.USAGE }); - if (usage) { - parser.usage(usage); - } - - Object.keys(cliOptions).forEach(function (flag) { - var opt = cliOptions[flag]; - var description = translate.message({ tag: opt.tag }); - if (description) { - parser.describe(flag, description); - } - }); - - return parser; -} - -module.exports = makeHelp; diff --git a/lib/shared/register-exports.js b/lib/shared/registerExports.js similarity index 85% rename from lib/shared/register-exports.js rename to lib/shared/registerExports.js index 572e9edc..09a31d0b 100644 --- a/lib/shared/register-exports.js +++ b/lib/shared/registerExports.js @@ -14,7 +14,7 @@ function registerExports(gulpInst, tasks) { return; } - gulpInst.task(task.displayName || taskName, task); + gulpInst.task(taskName, task); } } diff --git a/lib/shared/require-or-import.js b/lib/shared/require-or-import.js deleted file mode 100644 index af98aac5..00000000 --- a/lib/shared/require-or-import.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var pathToFileURL = require('url').pathToFileURL; - -var importESM; -try { - // Node.js <10 errors out with a SyntaxError when loading a script that uses import(). - // So a function is dynamically created to catch the SyntaxError at runtime instead of parsetime. - // That way we can keep supporting all Node.js versions all the way back to 0.10. - importESM = new Function('id', 'return import(id);'); -} catch (e) { - /* istanbul ignore next */ - importESM = null; -} - -function requireOrImport(path, callback) { - var err = null; - var cjs; - try { - cjs = require(path); - } catch (e) { - /* istanbul ignore else */ - if (pathToFileURL && importESM) { - // Because e.code is undefined on nyc process. - /* istanbul ignore else */ - // Check 'ERR_REQUIRE_ASYNC_MODULE' if on node v22.12.0 or later to allow importing from files using top level await. - if (e.code === 'ERR_REQUIRE_ESM' || process.env.NYC_CONFIG || e.code === 'ERR_REQUIRE_ASYNC_MODULE') { - // This is needed on Windows, because import() fails if providing a Windows file path. - var url = pathToFileURL(path); - importESM(url).then(function(esm) { callback(null, esm); }, callback); - return; - } - } - /* istanbul ignore next */ - err = e; - } - process.nextTick(function() { callback(err, cjs); }); -} - -module.exports = requireOrImport; diff --git a/lib/shared/tildify.js b/lib/shared/tildify.js deleted file mode 100644 index a9c61fce..00000000 --- a/lib/shared/tildify.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var replaceHomedir = require('replace-homedir'); - -function tildify(filepath) { - return replaceHomedir(filepath, '~'); -} - -module.exports = tildify; diff --git a/lib/shared/translate.js b/lib/shared/translate.js deleted file mode 100644 index 1c1939c8..00000000 --- a/lib/shared/translate.js +++ /dev/null @@ -1,305 +0,0 @@ -'use strict'; - -var util = require('util'); - -var chalk = require('chalk'); -var messages = require('@gulpjs/messages'); - -var tildify = require('./tildify'); -var formatTime = require('./log/format-hrtime'); - -function Timestamp() { - this.now = new Date(); -} - -Timestamp.prototype[util.inspect.custom] = function (depth, opts) { - var timestamp = this.now.toLocaleTimeString('en', { hour12: false }); - return '[' + opts.stylize(timestamp, 'date') + ']'; -}; - -function getDefaultMessage(data) { - switch (data.tag) { - case messages.PRELOAD_BEFORE: { - return 'Preloading external module: ' + chalk.magenta(data.name); - } - case messages.PRELOAD_SUCCESS: { - return 'Preloaded external module: ' + chalk.magenta(data.name) - } - case messages.PRELOAD_FAILURE: { - return chalk.yellow('Failed to preload external module: ') + chalk.magenta(data.name); - } - case messages.PRELOAD_ERROR: { - return chalk.yellow(data.error.toString()); - } - case messages.LOADER_SUCCESS: { - return 'Loaded external module: ' + chalk.magenta(data.name); - } - case messages.LOADER_FAILURE: { - return chalk.yellow('Failed to load external module: ') + chalk.magenta(data.name); - } - case messages.LOADER_ERROR: { - return chalk.yellow(data.error.toString()); - } - case messages.NODE_FLAGS: { - var nodeFlags = chalk.magenta(data.flags.join(', ')); - return 'Node flags detected: ' + nodeFlags; - } - case messages.RESPAWNED: { - var pid = chalk.magenta(data.pid); - return 'Respawned to PID: ' + pid; - } - case messages.MISSING_GULPFILE: { - return chalk.red('No gulpfile found'); - } - case messages.CWD_CHANGED: { - return 'Working directory changed to ' + chalk.magenta(tildify(data.cwd)); - } - case messages.UNSUPPORTED_GULP_VERSION: { - return chalk.red('Unsupported gulp version', data.version) - } - case messages.DESCRIPTION: { - return 'Tasks for ' + chalk.magenta(tildify(data.path)); - } - case messages.GULPFILE: { - return 'Using gulpfile ' + chalk.magenta(tildify(data.path)); - } - case messages.TASK_START: { - return "Starting '" + chalk.cyan(data.task) + "'..." - } - case messages.TASK_STOP: { - return "Finished '" + chalk.cyan(data.task) + "' after " + chalk.magenta(formatTime(data.duration)); - } - case messages.TASK_FAILURE: { - return "'" + chalk.cyan(data.task) + "' " + chalk.red('errored after') + ' ' + chalk.magenta(formatTime(data.duration)); - } - case messages.TASK_MISSING: { - if (data.similar) { - return chalk.red('Task never defined: ' + data.task + ' - did you mean? ' + data.similar.join(', ')) - + '\nTo list available tasks, try running: gulp --tasks'; - } else { - return chalk.red('Task never defined: ' + data.task) + - '\nTo list available tasks, try running: gulp --tasks'; - } - } - case messages.TASK_SYNC: { - return chalk.red('The following tasks did not complete: ') + chalk.cyan(data.tasks) + "\n" - + chalk.red('Did you forget to signal async completion?'); - } - case messages.MISSING_NODE_MODULES: { - return chalk.red('Local modules not found in') + ' ' + chalk.magenta(tildify(data.cwd)); - } - case messages.MISSING_GULP: { - return chalk.red('Local gulp not found in') + ' ' + chalk.magenta(tildify(data.cwd)); - } - case messages.YARN_INSTALL: { - return chalk.red('Try running: yarn install'); - } - case messages.NPM_INSTALL: { - return chalk.red('Try running: npm install'); - } - case messages.YARN_INSTALL_GULP: { - return chalk.red('Try running: yarn add gulp'); - } - case messages.NPM_INSTALL_GULP: { - return chalk.red('Try running: npm install gulp'); - } - case messages.GULPLOG_DEPRECATED: { - return chalk.yellow("gulplog v1 is deprecated. Please help your plugins update!"); - } - case messages.COMPLETION_TYPE_MISSING: { - return 'Missing completion type'; - } - case messages.COMPLETION_TYPE_UNKNOWN: { - return 'echo "gulp autocompletion rules for' + " '" + data.name + "' " + 'not found"' - } - case messages.ARGV_ERROR: { - return data.message; - } - case messages.EXEC_ERROR: { - return data.message; - } - case messages.TASK_ERROR: { - return data.message; - } - case messages.USAGE: { - return '\n' + chalk.bold('Usage:') + ' gulp ' + chalk.blue('[options]') + ' tasks'; - } - case messages.FLAG_HELP: { - return chalk.gray('Show this help.'); - } - case messages.FLAG_VERSION: { - return chalk.gray('Print the global and local gulp versions.'); - } - case messages.FLAG_PRELOAD: { - return chalk.gray( - 'Will preload a module before running the gulpfile. ' + - 'This is useful for transpilers but also has other applications.' - ); - } - case messages.FLAG_GULPFILE: { - return chalk.gray( - 'Manually set path of gulpfile. Useful if you have multiple gulpfiles. ' + - 'This will set the CWD to the gulpfile directory as well.' - ) - } - case messages.FLAG_CWD: { - return chalk.gray( - 'Manually set the CWD. The search for the gulpfile, ' + - 'as well as the relativity of all requires will be from here.' - ); - } - case messages.FLAG_TASKS: { - return chalk.gray('Print the task dependency tree for the loaded gulpfile.'); - } - case messages.FLAG_TASKS_SIMPLE: { - return chalk.gray('Print a plaintext list of tasks for the loaded gulpfile.'); - } - case messages.FLAG_TASKS_JSON: { - return chalk.gray( - 'Print the task dependency tree, ' + - 'in JSON format, for the loaded gulpfile.' - ); - } - case messages.FLAG_TASKS_DEPTH: { - return chalk.gray('Specify the depth of the task dependency tree.'); - } - case messages.FLAG_COMPACT_TASKS: { - return chalk.gray( - 'Reduce the output of task dependency tree by printing ' + - 'only top tasks and their child tasks.' - ); - } - case messages.FLAG_SORT_TASKS: { - return chalk.gray('Will sort top tasks of task dependency tree.'); - } - case messages.FLAG_COLOR: { - return chalk.gray( - 'Will force gulp and gulp plugins to display colors, ' + - 'even when no color support is detected.' - ); - } - case messages.FLAG_NO_COLOR: { - return chalk.gray( - 'Will force gulp and gulp plugins to not display colors, ' + - 'even when color support is detected.' - ); - } - case messages.FLAG_SILENT: { - return chalk.gray('Suppress all gulp logging.'); - } - case messages.FLAG_CONTINUE: { - return chalk.gray('Continue execution of tasks upon failure.'); - } - case messages.FLAG_SERIES: { - return chalk.gray('Run tasks given on the CLI in series (the default is parallel).'); - } - case messages.FLAG_LOG_LEVEL: { - return chalk.gray( - 'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' + - '-LLL is default.' - ); - } - case messages.TASK_NAME: { - return chalk.cyan(data.name); - } - case messages.TASK_DESCRIPTION: { - return chalk.white(data.description); - } - case messages.TASK_FLAG: { - return chalk.magenta(data.flag); - } - case messages.TASK_FLAG_DESCRIPTION: { - return chalk.white('…' + data.description); - } - case messages.BOX_DRAWINGS_LIGHT_UP_AND_RIGHT: { - return chalk.white('└'); - } - case messages.BOX_DRAWINGS_LIGHT_VERTICAL_AND_RIGHT: { - return chalk.white('├'); - } - case messages.BOX_DRAWINGS_LIGHT_HORIZONTAL: { - return chalk.white('─'); - } - case messages.BOX_DRAWINGS_LIGHT_DOWN_AND_HORIZONTAL: { - return chalk.white('┬'); - } - case messages.BOX_DRAWINGS_LIGHT_VERTICAL: { - return chalk.white('│'); - } - default: { - return data; - } - } -} - -function getDefaultTimestamp() { - return util.inspect(new Timestamp(), { colors: !!chalk.supportsColor }); -} - -function buildTranslations(cfg) { - cfg = cfg || {}; - - return { - message: function (data) { - // Don't allow an `undefined` message through - if (typeof data === 'undefined') { - data = Object.create(null); - } - - var message; - if (typeof cfg.message === 'function') { - try { - message = cfg.message(data); - } catch (err) { - console.error('A problem occurred with the user-defined `message()` function.'); - console.error('Please correct your `.gulp.*` config file.'); - } - } - - // If the user has provided a message, return it - if (message) { - return message; - } - - // Users can filter messages by explicitly returning `false` - if (message === false) { - return ''; - } - - // If the user hasn't returned a message or silenced it with `false` - // get the default message. Will return the first argument if the message - // is not defined in the `@gulpjs/messages` package - return getDefaultMessage(data); - }, - timestamp: function (data) { - // Don't allow an `undefined` message through - if (typeof data === 'undefined') { - data = Object.create(null); - } - - var time; - if (typeof cfg.timestamp === 'function') { - try { - time = cfg.timestamp(data); - } catch (err) { - console.error('A problem occurred with the user-defined `timestamp()` function.'); - console.error('Please correct your `.gulp.*` config file.'); - } - } - - // If the user has provided a timestamp, return it - if (time) { - return time; - } - - // Users can filter timestamps by explicitly returning `false` - if (time === false) { - return ''; - } - - return getDefaultTimestamp(); - } - } -} - -module.exports = buildTranslations; diff --git a/lib/shared/verifyDependencies.js b/lib/shared/verifyDependencies.js new file mode 100644 index 00000000..a0d4812c --- /dev/null +++ b/lib/shared/verifyDependencies.js @@ -0,0 +1,25 @@ +'use strict'; + +var matchdep = require('matchdep'); + +/** + * Given a collection of plugin names verifies this collection against + * the blacklist. Returns an object with: + * [plugin name]=>[blacklisting reason] + * or an empty object if none of the dependencies to check are blacklisted. + * + * @param pkg - package.json contents + * @param blacklist - contents of the blacklist in JSON format + */ +function verifyDependencies(pkg, blacklist) { + var blacklisted = matchdep + .filterAll(Object.keys(blacklist), pkg) + .reduce(function(blacklisted, pluginName) { + blacklisted[pluginName] = blacklist[pluginName]; + return blacklisted; + }, {}); + + return blacklisted; +} + +module.exports = verifyDependencies; diff --git a/lib/versioned/^3.7.0/format-error.js b/lib/versioned/^3.7.0/formatError.js similarity index 100% rename from lib/versioned/^3.7.0/format-error.js rename to lib/versioned/^3.7.0/formatError.js diff --git a/lib/versioned/^3.7.0/index.js b/lib/versioned/^3.7.0/index.js index bce66146..4879095e 100644 --- a/lib/versioned/^3.7.0/index.js +++ b/lib/versioned/^3.7.0/index.js @@ -1,71 +1,52 @@ 'use strict'; -var fs = require('fs'); - +var chalk = require('chalk'); var log = require('gulplog'); var stdout = require('mute-stdout'); -var messages = require('@gulpjs/messages'); - -var taskTree = require('./task-tree'); -var copyTree = require('../../shared/log/copy-tree'); +var tildify = require('tildify'); +var isString = require('lodash.isstring'); +var taskTree = require('./taskTree'); var logTasks = require('../../shared/log/tasks'); -var exit = require('../../shared/exit'); var logEvents = require('./log/events'); -var logTasksSimple = require('./log/tasks-simple'); -var registerExports = require('../../shared/register-exports'); -var requireOrImport = require('../../shared/require-or-import'); +var logTasksSimple = require('./log/tasksSimple'); +var registerExports = require('../../shared/registerExports'); -function execute(env, opts, translate) { +function execute(opts, env) { var tasks = opts._; var toRun = tasks.length ? tasks : ['default']; - if (opts.tasksSimple || opts.tasks || opts.tasksJson) { + if (opts.tasksSimple || opts.tasks) { // Mute stdout if we are listing tasks stdout.mute(); } // This is what actually loads up the gulpfile - requireOrImport(env.configPath, function(err, exported) { - // Before import(), if require() failed we got an unhandled exception on the module level. - // So console.error() & exit() were added here to mimic the old behavior as close as possible. - if (err) { - console.error(err); - exit(1); - } + var exported = require(env.configPath); + log.info('Using gulpfile', chalk.magenta(tildify(env.configPath))); - log.info({ tag: messages.GULPFILE, path: env.configPath }); + var gulpInst = require(env.modulePath); + logEvents(gulpInst); - var gulpInst = require(env.modulePath); - logEvents(gulpInst); + registerExports(gulpInst, exported); - registerExports(gulpInst, exported); + // Always unmute stdout after gulpfile is required + stdout.unmute(); - // Always unmute stdout after gulpfile is required - stdout.unmute(); - - var tree; + process.nextTick(function() { if (opts.tasksSimple) { return logTasksSimple(env, gulpInst); } if (opts.tasks) { - tree = taskTree(gulpInst.tasks); - tree.label = translate.message({ tag: messages.DESCRIPTION, path: env.configPath }); - return logTasks(tree, opts, function(task) { - return gulpInst.tasks[task].fn; - }, translate); - } - if (opts.tasksJson) { - tree = taskTree(gulpInst.tasks); - tree.label = translate.message({ tag: messages.DESCRIPTION, path: env.configPath }); - - var output = JSON.stringify(copyTree(tree, opts)); - - if (typeof opts.tasksJson === 'boolean') { - return console.log(output); + var tree = taskTree(gulpInst.tasks); + if (opts.description && isString(opts.description)) { + tree.label = opts.description; + } else { + tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath)); } - - return fs.writeFileSync(opts.tasksJson, output, 'utf-8'); + return logTasks(tree, opts.depth, function(task) { + return gulpInst.tasks[task].fn; + }); } gulpInst.start.apply(gulpInst, toRun); }); diff --git a/lib/versioned/^3.7.0/log/events.js b/lib/versioned/^3.7.0/log/events.js index 3fb63398..3b15be3b 100644 --- a/lib/versioned/^3.7.0/log/events.js +++ b/lib/versioned/^3.7.0/log/events.js @@ -1,10 +1,11 @@ 'use strict'; +var chalk = require('chalk'); var log = require('gulplog'); -var messages = require('@gulpjs/messages'); +var prettyTime = require('pretty-hrtime'); var exit = require('../../../shared/exit'); -var formatError = require('../format-error'); +var formatError = require('../formatError'); // Wire up logging events function logEvents(gulpInst) { @@ -25,20 +26,33 @@ function logEvents(gulpInst) { gulpInst.on('task_start', function(e) { // TODO: batch these // so when 5 tasks start at once it only logs one time with all 5 - log.info({ tag: messages.TASK_START, task: e.task }); + log.info('Starting', '\'' + chalk.cyan(e.task) + '\'...'); }); gulpInst.on('task_stop', function(e) { - log.info({ tag: messages.TASK_STOP, task: e.task, duration: e.hrDuration }); + var time = prettyTime(e.hrDuration); + log.info( + 'Finished', '\'' + chalk.cyan(e.task) + '\'', + 'after', chalk.magenta(time) + ); }); gulpInst.on('task_err', function(e) { - log.error({ tag: messages.TASK_FAILURE, task: e.task, duration: e.hrDuration }); - log.error({ tag: messages.TASK_ERROR, message: formatError(e) }); + var msg = formatError(e); + var time = prettyTime(e.hrDuration); + log.error( + '\'' + chalk.cyan(e.task) + '\'', + chalk.red('errored after'), + chalk.magenta(time) + ); + log.error(msg); }); gulpInst.on('task_not_found', function(err) { - log.error({ tag: messages.TASK_MISSING, task: err.task }); + log.error( + chalk.red('Task \'' + err.task + '\' is not in your gulpfile') + ); + log.error('Please check the documentation for proper gulpfile formatting'); exit(1); }); } diff --git a/lib/versioned/^3.7.0/log/tasks-simple.js b/lib/versioned/^3.7.0/log/tasksSimple.js similarity index 100% rename from lib/versioned/^3.7.0/log/tasks-simple.js rename to lib/versioned/^3.7.0/log/tasksSimple.js diff --git a/lib/versioned/^3.7.0/task-tree.js b/lib/versioned/^3.7.0/taskTree.js similarity index 60% rename from lib/versioned/^3.7.0/task-tree.js rename to lib/versioned/^3.7.0/taskTree.js index 8d689801..f7f3d9f5 100644 --- a/lib/versioned/^3.7.0/task-tree.js +++ b/lib/versioned/^3.7.0/taskTree.js @@ -4,24 +4,16 @@ module.exports = function(tasks) { var map = {}; var arr = []; Object.keys(tasks).forEach(function(taskname) { - var task = { - label: taskname, - type: 'task', - nodes: [], - }; + var task = { label: taskname, nodes: [], }; map[taskname] = task; arr.push(task); }); Object.keys(tasks).forEach(function(taskname) { var task = map[taskname]; tasks[taskname].dep.forEach(function(childname) { - var child = map[childname] || { - label: childname, - type: 'task', - nodes: [], - }; + var child = map[childname] || { label: childname, nodes: [], }; task.nodes.push(child); }); }); - return { label: 'Tasks', nodes: arr }; + return { label: 'Tasks', nodes: arr, }; }; diff --git a/lib/versioned/^4.0.0-alpha.1/index.js b/lib/versioned/^4.0.0-alpha.1/index.js new file mode 100644 index 00000000..1eb91b06 --- /dev/null +++ b/lib/versioned/^4.0.0-alpha.1/index.js @@ -0,0 +1,79 @@ +'use strict'; + +var fs = require('fs'); + +var log = require('gulplog'); +var chalk = require('chalk'); +var stdout = require('mute-stdout'); +var tildify = require('tildify'); +var isString = require('lodash.isstring'); + +var exit = require('../../shared/exit'); + +var logTasks = require('../../shared/log/tasks'); +var logEvents = require('../^4.0.0/log/events'); +var logSyncTask = require('../^4.0.0/log/syncTask'); +var logTasksSimple = require('../^4.0.0/log/tasksSimple'); +var registerExports = require('../../shared/registerExports'); + +function execute(opts, env) { + + var tasks = opts._; + var toRun = tasks.length ? tasks : ['default']; + + if (opts.tasksSimple || opts.tasks || opts.tasksJson) { + // Mute stdout if we are listing tasks + stdout.mute(); + } + + var gulpInst = require(env.modulePath); + logEvents(gulpInst); + logSyncTask(gulpInst); + + // This is what actually loads up the gulpfile + var exported = require(env.configPath); + + registerExports(gulpInst, exported); + + // Always unmute stdout after gulpfile is required + stdout.unmute(); + + process.nextTick(function() { + if (opts.tasksSimple) { + return logTasksSimple(gulpInst.tree()); + } + if (opts.tasks) { + var tree = {}; + if (opts.description && isString(opts.description)) { + tree.label = opts.description; + } else { + tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath)); + } + tree.nodes = gulpInst.tree({ deep: true }); + return logTasks(tree, opts.depth, function(taskname) { + return gulpInst.task(taskname); + }); + } + if (opts.tasksJson) { + var output = JSON.stringify(gulpInst.tree({ deep: true })); + if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) { + return console.log(output); + } + return fs.writeFileSync(opts.tasksJson, output, 'utf-8'); + } + try { + log.info('Using gulpfile', chalk.magenta(tildify(env.configPath))); + gulpInst.parallel(toRun)(function(err) { + if (err) { + exit(1); + } + }); + } catch (err) { + log.error(chalk.red(err.message)); + log.error('To list available tasks, try running: gulp --tasks'); + exit(1); + } + }); +} + +module.exports = execute; diff --git a/lib/versioned/^4.0.0-alpha.2/index.js b/lib/versioned/^4.0.0-alpha.2/index.js new file mode 100644 index 00000000..63c85b49 --- /dev/null +++ b/lib/versioned/^4.0.0-alpha.2/index.js @@ -0,0 +1,90 @@ +'use strict'; + +var fs = require('fs'); + +var log = require('gulplog'); +var chalk = require('chalk'); +var stdout = require('mute-stdout'); +var tildify = require('tildify'); +var isString = require('lodash.isstring'); + +var exit = require('../../shared/exit'); + +var logTasks = require('../../shared/log/tasks'); +var logEvents = require('../^4.0.0/log/events'); +var logSyncTask = require('../^4.0.0/log/syncTask'); +var logTasksSimple = require('../^4.0.0/log/tasksSimple'); +var registerExports = require('../../shared/registerExports'); + +var getTask = require('../^4.0.0/log/getTask'); + +function execute(opts, env) { + + var tasks = opts._; + var toRun = tasks.length ? tasks : ['default']; + + if (opts.tasksSimple || opts.tasks || opts.tasksJson) { + // Mute stdout if we are listing tasks + stdout.mute(); + } + + var gulpInst = require(env.modulePath); + logEvents(gulpInst); + logSyncTask(gulpInst); + + // This is what actually loads up the gulpfile + var exported = require(env.configPath); + + registerExports(gulpInst, exported); + + // Always unmute stdout after gulpfile is required + stdout.unmute(); + + process.nextTick(function() { + var tree; + + if (opts.tasksSimple) { + tree = gulpInst.tree(); + return logTasksSimple(tree.nodes); + } + if (opts.tasks) { + tree = gulpInst.tree({ deep: true }); + if (opts.description && isString(opts.description)) { + tree.label = opts.description; + } else { + tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath)); + } + + return logTasks(tree, opts.depth, getTask(gulpInst)); + } + if (opts.tasksJson) { + tree = gulpInst.tree({ deep: true }); + if (opts.description && isString(opts.description)) { + tree.label = opts.description; + } else { + tree.label = 'Tasks for ' + tildify(env.configPath); + } + + var output = JSON.stringify(tree); + + if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) { + return console.log(output); + } + return fs.writeFileSync(opts.tasksJson, output, 'utf-8'); + } + try { + log.info('Using gulpfile', chalk.magenta(tildify(env.configPath))); + gulpInst.parallel(toRun)(function(err) { + if (err) { + exit(1); + } + }); + } catch (err) { + log.error(chalk.red(err.message)); + log.error('To list available tasks, try running: gulp --tasks'); + exit(1); + } + }); +} + +module.exports = execute; diff --git a/lib/versioned/^4.0.0/format-error.js b/lib/versioned/^4.0.0/formatError.js similarity index 93% rename from lib/versioned/^4.0.0/format-error.js rename to lib/versioned/^4.0.0/formatError.js index 3d8a7718..b0f13889 100644 --- a/lib/versioned/^4.0.0/format-error.js +++ b/lib/versioned/^4.0.0/formatError.js @@ -1,7 +1,6 @@ 'use strict'; // Format orchestrator errors -/* istanbul ignore next */ function formatError(e) { if (!e.error) { return e.message; diff --git a/lib/versioned/^4.0.0/index.js b/lib/versioned/^4.0.0/index.js index 4adb9164..d434827c 100644 --- a/lib/versioned/^4.0.0/index.js +++ b/lib/versioned/^4.0.0/index.js @@ -3,23 +3,23 @@ var fs = require('fs'); var log = require('gulplog'); +var chalk = require('chalk'); var stdout = require('mute-stdout'); -var messages = require('@gulpjs/messages'); +var tildify = require('tildify'); +var isString = require('lodash.isstring'); var exit = require('../../shared/exit'); var logTasks = require('../../shared/log/tasks'); var logEvents = require('./log/events'); -var logSyncTask = require('./log/sync-task'); -var normalizeError = require('./normalize-error'); -var logTasksSimple = require('./log/tasks-simple'); -var registerExports = require('../../shared/register-exports'); +var logSyncTask = require('./log/syncTask'); +var logTasksSimple = require('./log/tasksSimple'); +var registerExports = require('../../shared/registerExports'); -var copyTree = require('../../shared/log/copy-tree'); -var getTask = require('./log/get-task'); -var requireOrImport = require('../../shared/require-or-import'); +var getTask = require('./log/getTask'); + +function execute(opts, env) { -function execute(env, opts, translate) { var tasks = opts._; var toRun = tasks.length ? tasks : ['default']; @@ -30,38 +30,42 @@ function execute(env, opts, translate) { var gulpInst = require(env.modulePath); logEvents(gulpInst); - logSyncTask(gulpInst, opts); + logSyncTask(gulpInst); // This is what actually loads up the gulpfile - requireOrImport(env.configPath, function(err, exported) { - // Before import(), if require() failed we got an unhandled exception on the module level. - // So console.error() & exit() were added here to mimic the old behavior as close as possible. - if (err) { - console.error(err); - exit(1); - } + var exported = require(env.configPath); - registerExports(gulpInst, exported); + registerExports(gulpInst, exported); - // Always unmute stdout after gulpfile is required - stdout.unmute(); + // Always unmute stdout after gulpfile is required + stdout.unmute(); + process.nextTick(function() { var tree; + if (opts.tasksSimple) { tree = gulpInst.tree(); return logTasksSimple(tree.nodes); } if (opts.tasks) { tree = gulpInst.tree({ deep: true }); - tree.label = translate.message({ tag: messages.DESCRIPTION, path: env.configPath }); + if (opts.description && isString(opts.description)) { + tree.label = opts.description; + } else { + tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath)); + } - return logTasks(tree, opts, getTask(gulpInst), translate); + return logTasks(tree, opts.depth, getTask(gulpInst)); } if (opts.tasksJson) { tree = gulpInst.tree({ deep: true }); - tree.label = translate.message({ tag: messages.DESCRIPTION, path: env.configPath }); + if (opts.description && isString(opts.description)) { + tree.label = opts.description; + } else { + tree.label = 'Tasks for ' + tildify(env.configPath); + } - var output = JSON.stringify(copyTree(tree, opts)); + var output = JSON.stringify(tree); if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) { return console.log(output); @@ -69,20 +73,15 @@ function execute(env, opts, translate) { return fs.writeFileSync(opts.tasksJson, output, 'utf-8'); } try { - log.info({ tag: messages.GULPFILE, path: env.configPath }); - var runMethod = opts.series ? 'series' : 'parallel'; - gulpInst[runMethod](toRun)(function(err) { + log.info('Using gulpfile', chalk.magenta(tildify(env.configPath))); + gulpInst.parallel(toRun)(function(err) { if (err) { exit(1); } }); } catch (err) { - normalizeError(err); - if (err.task) { - log.error({ tag: messages.TASK_MISSING, task: err.task, similar: err.similar }); - } else { - log.error({ tag: messages.EXEC_ERROR, message: err.message, error: err }); - } + log.error(chalk.red(err.message)); + log.error('To list available tasks, try running: gulp --tasks'); exit(1); } }); diff --git a/lib/versioned/^4.0.0/log/events.js b/lib/versioned/^4.0.0/log/events.js index af20f656..8c2f2d22 100644 --- a/lib/versioned/^4.0.0/log/events.js +++ b/lib/versioned/^4.0.0/log/events.js @@ -1,9 +1,9 @@ 'use strict'; var log = require('gulplog'); -var messages = require('@gulpjs/messages'); - -var formatError = require('../format-error'); +var chalk = require('chalk'); +var prettyTime = require('pretty-hrtime'); +var formatError = require('../formatError'); // Wire up logging events function logEvents(gulpInst) { @@ -11,26 +11,34 @@ function logEvents(gulpInst) { var loggedErrors = []; gulpInst.on('start', function(evt) { - /* istanbul ignore next */ // TODO: batch these // so when 5 tasks start at once it only logs one time with all 5 var level = evt.branch ? 'debug' : 'info'; - log[level]({ tag: messages.TASK_START, task: evt.name }); + log[level]('Starting', '\'' + chalk.cyan(evt.name) + '\'...'); }); gulpInst.on('stop', function(evt) { - /* istanbul ignore next */ + var time = prettyTime(evt.duration); var level = evt.branch ? 'debug' : 'info'; - log[level]({ tag: messages.TASK_STOP, task: evt.name, duration: evt.duration }); + log[level]( + 'Finished', '\'' + chalk.cyan(evt.name) + '\'', + 'after', chalk.magenta(time) + ); }); gulpInst.on('error', function(evt) { + var msg = formatError(evt); + var time = prettyTime(evt.duration); var level = evt.branch ? 'debug' : 'error'; - log[level]({ tag: messages.TASK_FAILURE, task: evt.name, duration: evt.duration }); + log[level]( + '\'' + chalk.cyan(evt.name) + '\'', + chalk.red('errored after'), + chalk.magenta(time) + ); // If we haven't logged this before, log it and add to list if (loggedErrors.indexOf(evt.error) === -1) { - log.error({ tag: messages.TASK_ERROR, message: formatError(evt) }); + log.error(msg); loggedErrors.push(evt.error); } }); diff --git a/lib/versioned/^4.0.0/log/get-task.js b/lib/versioned/^4.0.0/log/get-task.js deleted file mode 100644 index 144acb47..00000000 --- a/lib/versioned/^4.0.0/log/get-task.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -var isObject = require('../../../shared/is-object'); - -function getTask(gulpInst) { - return function(name) { - var task = gulpInst.task(name); - return { - description: getDescription(task), - flags: getFlags(task), - }; - }; -} - -function getDescription(task) { - if (typeof task.description === 'string') { - return task.description; - } - /* istanbul ignore else */ - if (typeof task.unwrap === 'function') { - var origFn = task.unwrap(); - if (typeof origFn.description === 'string') { - return origFn.description; - } - } - return undefined; -} - -function getFlags(task) { - if (isObject(task.flags)) { - return task.flags; - } - /* istanbul ignore else */ - if (typeof task.unwrap === 'function') { - var origFn = task.unwrap(); - if (isObject(origFn.flags)) { - return origFn.flags; - } - } - return undefined; -} - -module.exports = getTask; diff --git a/lib/versioned/^5.0.0/log/get-task.js b/lib/versioned/^4.0.0/log/getTask.js similarity index 67% rename from lib/versioned/^5.0.0/log/get-task.js rename to lib/versioned/^4.0.0/log/getTask.js index 144acb47..e437663a 100644 --- a/lib/versioned/^5.0.0/log/get-task.js +++ b/lib/versioned/^4.0.0/log/getTask.js @@ -1,6 +1,8 @@ 'use strict'; -var isObject = require('../../../shared/is-object'); +var isString = require('lodash.isstring'); +var isObject = require('lodash.isplainobject'); +var isFunction = require('lodash.isfunction'); function getTask(gulpInst) { return function(name) { @@ -13,13 +15,12 @@ function getTask(gulpInst) { } function getDescription(task) { - if (typeof task.description === 'string') { + if (isString(task.description)) { return task.description; } - /* istanbul ignore else */ - if (typeof task.unwrap === 'function') { + if (isFunction(task.unwrap)) { var origFn = task.unwrap(); - if (typeof origFn.description === 'string') { + if (isString(origFn.description)) { return origFn.description; } } @@ -30,8 +31,7 @@ function getFlags(task) { if (isObject(task.flags)) { return task.flags; } - /* istanbul ignore else */ - if (typeof task.unwrap === 'function') { + if (isFunction(task.unwrap)) { var origFn = task.unwrap(); if (isObject(origFn.flags)) { return origFn.flags; diff --git a/lib/versioned/^4.0.0/log/sync-task.js b/lib/versioned/^4.0.0/log/sync-task.js deleted file mode 100644 index 70c38a78..00000000 --- a/lib/versioned/^4.0.0/log/sync-task.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -var log = require('gulplog'); -var messages = require('@gulpjs/messages'); - -var tasks = {}; - -function warn() { - var taskKeys = Object.keys(tasks); - - if (!taskKeys.length) { - return; - } - - var taskNames = taskKeys.map(function(key) { - return tasks[key]; - }).join(', '); - - process.exitCode = 1; - - log.warn({ tag: messages.TASK_SYNC, tasks: taskNames }); -} - -function start(e) { - tasks[e.uid] = e.name; -} - -function clear(e) { - delete tasks[e.uid]; -} - -function clearAll() { - tasks = {}; -} - -function logSyncTask(gulpInst, opts) { - - process.once('exit', warn); - gulpInst.on('start', start); - gulpInst.on('stop', clear); - // When not running in --continue mode, we need to clear everything on error to avoid - // false positives. - gulpInst.on('error', opts.continue ? clear : clearAll); -} - -module.exports = logSyncTask; diff --git a/lib/versioned/^5.0.0/log/sync-task.js b/lib/versioned/^4.0.0/log/syncTask.js similarity index 55% rename from lib/versioned/^5.0.0/log/sync-task.js rename to lib/versioned/^4.0.0/log/syncTask.js index 70c38a78..493654fc 100644 --- a/lib/versioned/^5.0.0/log/sync-task.js +++ b/lib/versioned/^4.0.0/log/syncTask.js @@ -1,7 +1,7 @@ 'use strict'; var log = require('gulplog'); -var messages = require('@gulpjs/messages'); +var chalk = require('chalk'); var tasks = {}; @@ -16,9 +16,13 @@ function warn() { return tasks[key]; }).join(', '); - process.exitCode = 1; - - log.warn({ tag: messages.TASK_SYNC, tasks: taskNames }); + log.warn( + chalk.red('The following tasks did not complete:'), + chalk.cyan(taskNames) + ); + log.warn( + chalk.red('Did you forget to signal async completion?') + ); } function start(e) { @@ -29,18 +33,12 @@ function clear(e) { delete tasks[e.uid]; } -function clearAll() { - tasks = {}; -} - -function logSyncTask(gulpInst, opts) { +function logSyncTask(gulpInst) { process.once('exit', warn); gulpInst.on('start', start); gulpInst.on('stop', clear); - // When not running in --continue mode, we need to clear everything on error to avoid - // false positives. - gulpInst.on('error', opts.continue ? clear : clearAll); + gulpInst.on('error', clear); } module.exports = logSyncTask; diff --git a/lib/versioned/^4.0.0/log/tasks-simple.js b/lib/versioned/^4.0.0/log/tasksSimple.js similarity index 100% rename from lib/versioned/^4.0.0/log/tasks-simple.js rename to lib/versioned/^4.0.0/log/tasksSimple.js diff --git a/lib/versioned/^4.0.0/normalize-error.js b/lib/versioned/^4.0.0/normalize-error.js deleted file mode 100644 index 0f58d0c4..00000000 --- a/lib/versioned/^4.0.0/normalize-error.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -// Normalize an undertaker v1 error like an undertaker v2 error -function normalizeError(err) { - /* istanbul ignore if */ - if (!err || !err.message) { - return; - } - - var fixed0 = 'Task never defined: '; - var fixed1 = ' - did you mean? '; - - if (err.message.startsWith(fixed0)) { - var task = err.message.slice(fixed0.length); - var index = task.indexOf(fixed1); - - if (index >= 0) { - err.similar = task.slice(index + fixed1.length).split(', '); - err.task = task.slice(0, index); - } else { - err.task = task - } - } -} - -module.exports = normalizeError; diff --git a/lib/versioned/^5.0.0/format-error.js b/lib/versioned/^5.0.0/format-error.js deleted file mode 100644 index 3d8a7718..00000000 --- a/lib/versioned/^5.0.0/format-error.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -// Format orchestrator errors -/* istanbul ignore next */ -function formatError(e) { - if (!e.error) { - return e.message; - } - - // PluginError - if (typeof e.error.showStack === 'boolean') { - return e.error.toString(); - } - - // Normal error - if (e.error.stack) { - return e.error.stack; - } - - // Unknown (string, number, etc.) - return new Error(String(e.error)).stack; -} - -module.exports = formatError; diff --git a/lib/versioned/^5.0.0/index.js b/lib/versioned/^5.0.0/index.js deleted file mode 100644 index d3258b3b..00000000 --- a/lib/versioned/^5.0.0/index.js +++ /dev/null @@ -1,89 +0,0 @@ -'use strict'; - -var fs = require('fs'); - -var log = require('gulplog'); -var stdout = require('mute-stdout'); -var messages = require('@gulpjs/messages'); - -var exit = require('../../shared/exit'); - -var logTasks = require('../../shared/log/tasks'); -var logEvents = require('./log/events'); -var logSyncTask = require('./log/sync-task'); -var logTasksSimple = require('./log/tasks-simple'); -var registerExports = require('../../shared/register-exports'); - -var copyTree = require('../../shared/log/copy-tree'); -var getTask = require('./log/get-task'); -var requireOrImport = require('../../shared/require-or-import'); - -function execute(env, opts, translate) { - var tasks = opts._; - var toRun = tasks.length ? tasks : ['default']; - - if (opts.tasksSimple || opts.tasks || opts.tasksJson) { - // Mute stdout if we are listing tasks - stdout.mute(); - } - - var gulpInst = require(env.modulePath); - logEvents(gulpInst); - logSyncTask(gulpInst, opts); - - // This is what actually loads up the gulpfile - requireOrImport(env.configPath, function(err, exported) { - // Before import(), if require() failed we got an unhandled exception on the module level. - // So console.error() & exit() were added here to mimic the old behavior as close as possible. - if (err) { - console.error(err); - exit(1); - } - - registerExports(gulpInst, exported); - - // Always unmute stdout after gulpfile is required - stdout.unmute(); - - var tree; - if (opts.tasksSimple) { - tree = gulpInst.tree(); - return logTasksSimple(tree.nodes); - } - if (opts.tasks) { - tree = gulpInst.tree({ deep: true }); - tree.label = translate.message({ tag: messages.DESCRIPTION, path: env.configPath }); - - return logTasks(tree, opts, getTask(gulpInst), translate); - } - if (opts.tasksJson) { - tree = gulpInst.tree({ deep: true }); - tree.label = translate.message({ tag: messages.DESCRIPTION, path: env.configPath }); - - var output = JSON.stringify(copyTree(tree, opts)); - - if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) { - return console.log(output); - } - return fs.writeFileSync(opts.tasksJson, output, 'utf-8'); - } - try { - log.info({ tag: messages.GULPFILE, path: env.configPath }); - var runMethod = opts.series ? 'series' : 'parallel'; - gulpInst[runMethod](toRun)(function(err) { - if (err) { - exit(1); - } - }); - } catch (err) { - if (err.task) { - log.error({ tag: messages.TASK_MISSING, task: err.task, similar: err.similar }); - } else { - log.error({ tag: messages.EXEC_ERROR, message: err.message, error: err }); - } - exit(1); - } - }); -} - -module.exports = execute; diff --git a/lib/versioned/^5.0.0/log/events.js b/lib/versioned/^5.0.0/log/events.js deleted file mode 100644 index af20f656..00000000 --- a/lib/versioned/^5.0.0/log/events.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var log = require('gulplog'); -var messages = require('@gulpjs/messages'); - -var formatError = require('../format-error'); - -// Wire up logging events -function logEvents(gulpInst) { - - var loggedErrors = []; - - gulpInst.on('start', function(evt) { - /* istanbul ignore next */ - // TODO: batch these - // so when 5 tasks start at once it only logs one time with all 5 - var level = evt.branch ? 'debug' : 'info'; - log[level]({ tag: messages.TASK_START, task: evt.name }); - }); - - gulpInst.on('stop', function(evt) { - /* istanbul ignore next */ - var level = evt.branch ? 'debug' : 'info'; - log[level]({ tag: messages.TASK_STOP, task: evt.name, duration: evt.duration }); - }); - - gulpInst.on('error', function(evt) { - var level = evt.branch ? 'debug' : 'error'; - log[level]({ tag: messages.TASK_FAILURE, task: evt.name, duration: evt.duration }); - - // If we haven't logged this before, log it and add to list - if (loggedErrors.indexOf(evt.error) === -1) { - log.error({ tag: messages.TASK_ERROR, message: formatError(evt) }); - loggedErrors.push(evt.error); - } - }); -} - -module.exports = logEvents; diff --git a/lib/versioned/^5.0.0/log/tasks-simple.js b/lib/versioned/^5.0.0/log/tasks-simple.js deleted file mode 100644 index 65cde515..00000000 --- a/lib/versioned/^5.0.0/log/tasks-simple.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -function logTasksSimple(nodes) { - console.log(nodes.join('\n').trim()); -} - -module.exports = logTasksSimple; diff --git a/package.json b/package.json index 372e4bd3..5e316222 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "gulp-cli", - "version": "3.1.0", + "version": "1.2.2", "description": "Command line interface for gulp", - "author": "Gulp Team (https://gulpjs.com/)", + "author": "Gulp Team (http://gulpjs.com/)", "contributors": [], - "homepage": "https://gulpjs.com", + "homepage": "http://gulpjs.com", "repository": "gulpjs/gulp-cli", "license": "MIT", "man": "gulp.1", "engines": { - "node": ">=10.13.0" + "node": ">= 0.10" }, "main": "index.js", "bin": { @@ -23,50 +23,52 @@ "gulp.1" ], "scripts": { - "lint": "eslint .", - "manpage": "marked-man --name gulp docs/CLI.md > gulp.1", + "lint": "eslint . && jscs index.js bin/ lib/ test/", + "prepublish": "marked-man --name gulp docs/CLI.md > gulp.1", "pretest": "npm run lint", - "test": "mocha --async-only --timeout 5000 test/lib test", - "cover": "nyc mocha --async-only --timeout 5000 test/lib test" + "test": "mocha --async-only --timeout 3000", + "cover": "nyc --reporter=lcov --reporter=text-summary npm test", + "coveralls": "nyc --reporter=text-lcov npm test | coveralls", + "changelog": "github-changes -o gulpjs -r gulp-cli -b master -f ./CHANGELOG.md --order-semver --use-commit-body" }, "dependencies": { - "@gulpjs/messages": "^1.1.0", - "chalk": "^4.1.2", - "copy-props": "^4.0.0", - "gulplog": "^2.2.0", - "interpret": "^3.1.1", - "liftoff": "^5.0.1", - "mute-stdout": "^2.0.0", - "replace-homedir": "^2.0.0", - "semver-greatest-satisfied-range": "^2.0.0", - "string-width": "^4.2.3", - "v8flags": "^4.0.0", - "yargs": "^16.2.0" + "archy": "^1.0.0", + "chalk": "^1.1.0", + "fancy-log": "^1.1.0", + "gulplog": "^1.0.0", + "interpret": "^1.0.0", + "liftoff": "^2.3.0", + "lodash.isfunction": "^3.0.8", + "lodash.isplainobject": "^4.0.4", + "lodash.isstring": "^4.0.1", + "lodash.merge": "^4.5.1", + "lodash.sortby": "^4.5.0", + "matchdep": "^1.0.0", + "mute-stdout": "^1.0.0", + "pretty-hrtime": "^1.0.0", + "semver-greatest-satisfied-range": "^1.0.0", + "tildify": "^1.0.0", + "v8flags": "^2.0.9", + "wreck": "^6.3.0", + "yargs": "^3.28.0" }, "devDependencies": { - "@babel/core": "^7.20.2", - "@babel/preset-env": "^7.20.2", - "@babel/register": "^7.18.9", - "@gulpjs/gulplog-v1": "npm:gulplog@1.0.0", - "eslint": "^7.32.0", - "eslint-config-gulp": "^5.0.1", - "expect": "^27.5.1", - "gulp": "^4.0.2", - "marked-man": "^0.7.0", - "marked": "^0.7.0", - "mocha": "^8.4.0", - "nyc": "^15.1.0", - "rimraf": "^3.0.2", - "semver": "^7.3.8" - }, - "nyc": { - "reporter": [ - "lcov", - "text-summary" - ] - }, - "prettier": { - "singleQuote": true + "babel-preset-es2015": "^6.5.0", + "babel-register": "^6.5.1", + "coveralls": "^2.7.0", + "eslint": "^1.7.3", + "eslint-config-gulp": "^2.0.0", + "expect": "^1.20.2", + "fs-extra": "^0.26.1", + "github-changes": "^1.0.1", + "gulp": "gulpjs/gulp#4.0", + "gulp-test-tools": "^0.6.0", + "istanbul": "^0.4.5", + "jscs": "^2.3.5", + "jscs-preset-gulp": "^1.0.0", + "marked-man": "^0.1.3", + "mocha": "^3.2.0", + "nyc": "^10.0.0" }, "keywords": [ "build", diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000..06b940f7 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "gulp/test" +} diff --git a/test/completion.js b/test/completion.js index 3c30ad74..46677ffa 100644 --- a/test/completion.js +++ b/test/completion.js @@ -1,12 +1,10 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; +var runner = require('gulp-test-tools').gulpRunner; var path = require('path'); var fs = require('fs'); -var gulp = require('./tool/gulp-cmd'); - describe('flag: --completion', function() { ['bash', 'fish', 'powershell', 'zsh'].forEach(function(type) { @@ -14,11 +12,11 @@ describe('flag: --completion', function() { var file = path.resolve(__dirname, '../completion', type); var expected = fs.readFileSync(file, 'utf8') + '\n'; - exec(gulp('--completion=' + type), cb); + runner({ verbose: false }) + .gulp('--completion=' + type) + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { expect(stdout).toEqual(expected); done(err); } @@ -26,25 +24,27 @@ describe('flag: --completion', function() { }); it('shows error message for unknown completion type', function(done) { - var expected = 'echo "gulp autocompletion rules for \'unknown\' not found"\n'; + var expected = + 'echo "gulp autocompletion rules for \'unknown\' not found"\n'; - exec(gulp('--completion=unknown'), cb); + runner({ verbose: false }) + .gulp('--completion=unknown') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { + expect(err).toExist(); expect(stdout).toEqual(expected); done(); } }); it('shows error message for missing completion type', function(done) { - exec(gulp('--completion'), cb); + runner({ verbose: false }) + .gulp('--completion') + .run(cb); function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); expect(stderr).toMatch('Missing completion type'); - expect(stdout).toEqual(''); done(); } }); diff --git a/test/config-flags-compact-tasks.js b/test/config-flags-compact-tasks.js deleted file mode 100644 index 57fd19a1..00000000 --- a/test/config-flags-compact-tasks.js +++ /dev/null @@ -1,75 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); -var fs = require('fs'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/compactTasks'); -var expectedDir = path.join(__dirname, 'expected'); - -describe('config: flags.compactTasks', function() { - - it('Should compact task lists when `flags.compactTasks` is true in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-compact.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expected = sliceLines(expected, 2); - stdout = sliceLines(stdout, 2); - expect(stdout).toEqual(expected); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should not compact task lists when `flags.compactTasks` is false in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-unsorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expected = sliceLines(expected, 2); - stdout = sliceLines(stdout, 2); - expect(stdout).toEqual(expected); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should overridden by cli flag: --compact-tasks', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--tasks', '--compact-tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-compact.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expected = sliceLines(expected, 2); - stdout = sliceLines(stdout, 2); - expect(stdout).toEqual(expected); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should overridden by cli flag: --no-compact-tasks', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--tasks', '--no-compact-tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-unsorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expected = sliceLines(expected, 2); - stdout = sliceLines(stdout, 2); - expect(stdout).toEqual(expected); - expect(stderr).toEqual(''); - done(err); - } - }); -}); diff --git a/test/config-flags-continue.js b/test/config-flags-continue.js deleted file mode 100644 index 5764bfbb..00000000 --- a/test/config-flags-continue.js +++ /dev/null @@ -1,102 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/continue'); - -describe('config: flags.continue', function() { - - it('Should continue if `flags.continue` is true in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - stdout = sliceLines(stdout, 1); - expect(stdout).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'err\'...\n' + - 'Starting \'next\'...\n' + - 'Finished \'next\' after ?\n' + - '' - ); - stderr = sliceLines(stderr, 0, 2); - expect(stderr).toEqual( - '\'err\' errored after ?\n' + - 'Error: Error!' - ); - done(); - } - }); - - it('Should not continue if `flags.continue` is false in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - stdout = sliceLines(stdout, 1); - expect(stdout).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'err\'...\n' + - '' - ); - stderr = sliceLines(stderr, 0, 2); - expect(stderr).toEqual( - '\'err\' errored after ?\n' + - 'Error: Error!' - ); - done(); - } - }); - - it('Should overridden by cli flag: --continue', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--continue'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - stdout = sliceLines(stdout, 1); - expect(stdout).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'err\'...\n' + - 'Starting \'next\'...\n' + - 'Finished \'next\' after ?\n' + - '' - ); - stderr = sliceLines(stderr, 0, 2); - expect(stderr).toEqual( - '\'err\' errored after ?\n' + - 'Error: Error!' - ); - done(); - } - }); - - it('Should overridden by cli flag: --no-continue', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--no-continue'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - stdout = sliceLines(stdout, 1); - expect(stdout).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'err\'...\n' + - '' - ); - stderr = sliceLines(stderr, 0, 2); - expect(stderr).toEqual( - '\'err\' errored after ?\n' + - 'Error: Error!' - ); - done(); - } - }); - -}); diff --git a/test/config-flags-gulpfile.js b/test/config-flags-gulpfile.js deleted file mode 100644 index 4d62031c..00000000 --- a/test/config-flags-gulpfile.js +++ /dev/null @@ -1,159 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/gulpfile'); -var prjDir = path.join(baseDir, 'prj'); - -describe('config: gulpfile', function() { - - it('Should configure with a .gulp.* file', function(done) { - var opts = { cwd: prjDir }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 3, 5)).toEqual( - 'This gulpfile : ' + path.join(baseDir, 'is/here/gulpfile-by-prj-cfg.js') + '\n' + - 'The current directory : ' + path.join(baseDir, 'is/here') - ); - done(err); - } - }); - - it('Should configure with a .gulp.* file in the directory specified by --cwd', function(done) { - var opts = { cwd: prjDir }; - exec(gulp('--cwd ../cwd'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 3, 5)).toEqual( - 'This gulpfile : ' + path.join(baseDir, 'is/here/gulpfile-by-cwd-cfg.js') + '\n' + - 'The current directory : ' + path.join(baseDir, 'cwd') - ); - done(err); - } - }); - - it('Should configure with a .gulp.* file found up', function(done) { - var opts = { cwd: path.join(prjDir, 'findup') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 3, 5)).toEqual( - 'This gulpfile : ' + path.join(baseDir, 'is/here/gulpfile-by-prj-cfg.js') + '\n' + - 'The current directory : ' + path.join(baseDir, 'is/here') - ); - done(err); - } - }); - - it('Should configure with a .gulp.* file found up the directory specified by --cwd', function(done) { - var opts = { cwd: prjDir }; - exec(gulp('--cwd ../cwd/findup'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 3, 5)).toEqual( - 'This gulpfile : ' + path.join(baseDir, 'is/here/gulpfile-by-cwd-cfg.js') + '\n' + - 'The current directory : ' + path.join(baseDir, 'cwd/findup') - ); - done(err); - } - }); - - it('Should ignore a ./gulp.* file if another directory is specified by --cwd', function(done) { - var opts = { cwd: prjDir }; - exec(gulp('--cwd ../is/here'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 3, 5)).toEqual( - 'This gulpfile : ' + path.join(baseDir, 'is/here/gulpfile.js') + '\n' + - 'The current directory : ' + path.join(baseDir, 'is/here') - ); - done(err); - } - }); - - it('Should ignore a ./.gulp.* file if another gulpfile is specified by --gulpfile', function(done) { - var opts = { cwd: prjDir }; - exec(gulp('--gulpfile ../is/here/gulpfile.js'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 3, 5)).toEqual( - 'This gulpfile : ' + path.join(baseDir, 'is/here/gulpfile.js') + '\n' + - 'The current directory : ' + path.join(baseDir, 'is/here') - ); - done(err); - } - }); - - it('Should overridden by cli flag: --gulpfile', function(done) { - var opts = { cwd: path.join(baseDir, 'override-by-cliflag') }; - exec(gulp('--gulpfile mygulpfile.js'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 2, 3)).toEqual( - 'Gulpfile : ' + path.join(baseDir, 'override-by-cliflag/mygulpfile.js') - ); - done(err); - } - }); - - it('Should autoload a module for loading a specified gulpfile', function(done) { - this.timeout(0); - - var opts = { cwd: path.join(baseDir, 'autoload') }; - exec(gulp('dist'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Loaded external module: @babel/register'); - expect(sliceLines(stdout, 5, 6)).toEqual('clean!'); - expect(sliceLines(stdout, 8, 9)).toEqual('build!'); - done(err); - } - }); - - it('Should output error logs of autoload if fail to load module for a specified gulpfile', function(done) { - var opts = { cwd: path.join(baseDir, 'autoload-fail') }; - exec(gulp('dist'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stderr).not.toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Failed to load external module: coffeescript/register'); - expect(sliceLines(stdout, 1, 2)).toMatch('Error: Cannot find module \'coffeescript/register\''); - done(); - } - }); - - it('Should not find up but use config file in current directory', function(done) { - var opts = { cwd: path.join(baseDir, 'use-current-cfg/current-dir') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 2, 3)).toEqual(path.join(opts.cwd, 'gulpfile-2.js')); - done(err); - } - }); -}); diff --git a/test/config-flags-log-level.js b/test/config-flags-log-level.js deleted file mode 100644 index 8d187cf0..00000000 --- a/test/config-flags-log-level.js +++ /dev/null @@ -1,206 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var eraseTime = require('./tool/erase-time'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/logLevel'); - -describe('config: flag.logLevel', function() { - - describe('log level 3 by default', function() { - - it('Should output error log', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--gulpfile x'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual('No gulpfile found\n'); - done(); - } - }); - - it('Should output warn log', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--preload mymodule'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1, 3)).toMatch( - 'Failed to preload external module: mymodule\n' + - 'Error: Cannot find module \'mymodule\' from \''); - done(); - } - }); - - it('Should output info log', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 2)).toMatch( - 'Node flags detected: --harmony\n' + - 'Respawned to PID: '); - done(err); - } - }); - }); - - describe('log level 1 by config `flags.logLevel`', function() { - - it('Should output error log', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--gulpfile x'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual('No gulpfile found\n'); - done(); - } - }); - - it('Should output warn log', function(done) { - var opts = { cwd: path.join(baseDir, 'L') }; - exec(gulp('--preload mymodule'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stderr).toEqual(''); - done(); - } - }); - - it('Should output info log', function(done) { - var opts = { cwd: path.join(baseDir, 'L') }; - exec(gulp('--harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(''); - done(err); - } - }); - }); - - describe('log level 2 by config `flags.logLevel`', function() { - it('Should output error log', function(done) { - var opts = { cwd: path.join(baseDir, 'LL') }; - exec(gulp('--gulpfile x'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual('No gulpfile found\n'); - done(); - } - }); - - it('Should output warn log', function(done) { - var opts = { cwd: path.join(baseDir, 'LL') }; - exec(gulp('--preload mymodule'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseTime(stdout)).toMatch( - 'Failed to preload external module: mymodule\n' + - 'Error: Cannot find module \'mymodule\' from \''); - done(); - } - }); - - it('Should output info log', function(done) { - var opts = { cwd: path.join(baseDir, 'LL') }; - exec(gulp('--harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(''); - done(err); - } - }); - }); - - describe('log level 3 by config `flags.logLevel`', function() { - it('Should output error log', function(done) { - var opts = { cwd: path.join(baseDir, 'LLL') }; - exec(gulp('--gulpfile x'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual('No gulpfile found\n'); - done(); - } - }); - - it('Should output warn log', function(done) { - var opts = { cwd: path.join(baseDir, 'LLL') }; - exec(gulp('--preload mymodule'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseTime(stdout)).toMatch( - 'Failed to preload external module: mymodule\n' + - 'Error: Cannot find module \'mymodule\' from \''); - done(); - } - }); - - it('Should output info log', function(done) { - var opts = { cwd: path.join(baseDir, 'LLL') }; - exec(gulp('--harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 2)).toMatch( - 'Node flags detected: --harmony\n' + - 'Respawned to PID: '); - done(err); - } - }); - }); - - describe('Overridden by cli flag: -L/-LL/-LLL', function() { - it('Should not output info log by -L', function(done) { - var opts = { cwd: path.join(baseDir, 'LLL') }; - exec(gulp('-L', '--preload mymodule'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should output info log by -LLL', function(done) { - var opts = { cwd: path.join(baseDir, 'L') }; - exec(gulp('-LLL', '--harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 2)).toMatch( - 'Node flags detected: --harmony\n' + - 'Respawned to PID: '); - done(err); - } - }); - }); -}); diff --git a/test/config-flags-node-flags.js b/test/config-flags-node-flags.js deleted file mode 100644 index eb9c00cb..00000000 --- a/test/config-flags-node-flags.js +++ /dev/null @@ -1,86 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/nodeFlags'); - -describe('config: nodeFlags', function() { - - it('Should respawn by a node flag: --lazy', function(done) { - var opts = { cwd: path.join(baseDir, 'string') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Node flags detected: --lazy'); - expect(sliceLines(stdout, 1, 3)).toMatch('Respawned to PID: '); - done(err); - } - }); - - it('Should respawn by a node flag: --lazy --trace-deprecation', function(done) { - var opts = { cwd: path.join(baseDir, 'array') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Node flags detected: --lazy, --trace-deprecation'); - expect(sliceLines(stdout, 1, 3)).toMatch('Respawned to PID: '); - done(err); - } - }); - - it('Should respawn with flags in config file and command line', function(done) { - var opts = { cwd: path.join(baseDir, 'string') }; - exec(gulp('--harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Node flags detected: --lazy, --harmony'); - expect(sliceLines(stdout, 1, 3)).toMatch('Respawned to PID: '); - done(err); - } - }); - - it('Should not respawn when a node flag is specified to undefined', function(done) { - var opts = { cwd: path.join(baseDir, 'undefined') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toMatch('Using gulpfile '); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'default\'...\n' + - 'Default\n' + - 'Finished \'default\' after ?\n' + - ''); - done(err); - } - }); - - it('Should not respawn when a node flag is specified to null', function(done) { - var opts = { cwd: path.join(baseDir, 'null') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toMatch('Using gulpfile '); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'default\'...\n' + - 'Default\n' + - 'Finished \'default\' after ?\n' + - ''); - done(err); - } - }); -}); diff --git a/test/config-flags-preload.js b/test/config-flags-preload.js deleted file mode 100644 index e406da09..00000000 --- a/test/config-flags-preload.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/preload'); - -describe('config: preload', function() { - - it('Should configure with an array in a .gulp.* file', function(done) { - var opts = { cwd: path.join(baseDir, 'array') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ./preload_one'); - expect(sliceLines(stdout, 1, 2)).toEqual('Preloaded external module: ./preload_one'); - expect(sliceLines(stdout, 2, 3)).toEqual('Preloading external module: ./preload_two'); - expect(sliceLines(stdout, 3, 4)).toEqual('Preloaded external module: ./preload_two'); - expect(sliceLines(stdout, 6, 7)).toEqual('preload one!'); - expect(sliceLines(stdout, 7, 8)).toEqual('preload two!'); - done(err); - } - }); - - it('Should configure with a string in a .gulp.* file', function(done) { - var opts = { cwd: path.join(baseDir, 'string') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ./preload'); - expect(sliceLines(stdout, 1, 2)).toEqual('Preloaded external module: ./preload'); - expect(sliceLines(stdout, 4, 5)).toEqual('hello preload!'); - done(err); - } - }); - - it('Combines --preload flag with .gulp.* file flags.preload', function(done) { - var opts = { cwd: path.join(baseDir, 'join-flags') }; - exec(gulp('--preload ./preload_one'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ./preload_one'); - expect(sliceLines(stdout, 1, 2)).toEqual('Preloaded external module: ./preload_one'); - expect(sliceLines(stdout, 2, 3)).toEqual('Preloading external module: ./preload_two'); - expect(sliceLines(stdout, 3, 4)).toEqual('Preloaded external module: ./preload_two'); - expect(sliceLines(stdout, 6, 7)).toEqual('preload one!'); - expect(sliceLines(stdout, 7, 8)).toEqual('preload two!'); - done(err); - } - }); - - it('resolves relative requires against cwd', function(done) { - var opts = { cwd: path.join(__dirname, 'fixtures/config') }; - exec(gulp('--cwd flags/preload/with-cwd'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ../preload'); - expect(sliceLines(stdout, 1, 2)).toEqual('Preloaded external module: ../preload'); - expect(sliceLines(stdout, 5, 6)).toEqual('hello preload!'); - done(err); - } - }); - - it('works with absolute paths, ignoring cwd', function(done) { - var opts = { cwd: path.join(__dirname, 'fixtures/config') }; - exec(gulp('--cwd flags/preload/with-absolute'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var absolute = path.join(__dirname, './fixtures/config/flags/preload/preload'); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ' + absolute); - expect(sliceLines(stdout, 1, 2)).toEqual('Preloaded external module: ' + absolute); - expect(sliceLines(stdout, 5, 6)).toEqual('hello preload!'); - done(err); - } - }); -}); diff --git a/test/config-flags-series.js b/test/config-flags-series.js deleted file mode 100644 index b298322a..00000000 --- a/test/config-flags-series.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/series'); - -describe('config: flags.series', function() { - - it('Should run in series if `flags.series` is true in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('task1', 'task2'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'task1\'...\n' + - 'Finished \'task1\' after ?\n' + - 'Starting \'task2\'...\n' + - 'Finished \'task2\' after ?\n' + - '' - ); - done(); - } - }); - - it('Should run in parallel if `flags.series` is false in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('task1', 'task2'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'task1\'...\n' + - 'Starting \'task2\'...\n' + - 'Finished \'task2\' after ?\n' + - 'Finished \'task1\' after ?\n' + - '' - ); - done(); - } - }); - - it('Should overridden by cli flag: --series', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--series', 'task1', 'task2'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'task1\'...\n' + - 'Finished \'task1\' after ?\n' + - 'Starting \'task2\'...\n' + - 'Finished \'task2\' after ?\n' + - '' - ); - done(); - } - }); - - it('Should overridden by cli flag: --no-series', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--no-series', 'task1', 'task2'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'task1\'...\n' + - 'Starting \'task2\'...\n' + - 'Finished \'task2\' after ?\n' + - 'Finished \'task1\' after ?\n' + - '' - ); - done(); - } - }); -}); diff --git a/test/config-flags-silent.js b/test/config-flags-silent.js deleted file mode 100644 index 527bbc8f..00000000 --- a/test/config-flags-silent.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/silent'); - -describe('config: flags.silent', function() { - - it('Should be silent if `flags.silent` is true in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(''); - done(err); - } - }); - - it('Should not be silent if `flags.silent` is false in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'default\'...\n' + - 'Finished \'default\' after ?\n' + - '' - ); - done(err); - } - }); - - it('Should overridden by cli flag: --silent', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--silent'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(''); - done(err); - } - }); - - it('Should overridden by cli flag: --no-silent', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--no-silent'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1)).toEqual( - 'Starting \'default\'...\n' + - 'Finished \'default\' after ?\n' + - '' - ); - done(err); - } - }); - -}); diff --git a/test/config-flags-sort-tasks.js b/test/config-flags-sort-tasks.js deleted file mode 100644 index 197f8d39..00000000 --- a/test/config-flags-sort-tasks.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); -var fs = require('fs'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/sortTasks'); -var expectedDir = path.join(__dirname, 'expected'); - -describe('config: flags.sortTasks', function() { - - it('Should sort top tasks in task list when `flags.sortTasks` is true in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-sorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 2)).toEqual(sliceLines(expected, 2)); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should sort top tasks in task list when `flags.sortTasks` is false in .gulp.*', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-unsorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 2)).toEqual(sliceLines(expected, 2)); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should overridden by cli flag: --sort-tasks', function(done) { - var opts = { cwd: path.join(baseDir, 'f') }; - exec(gulp('--tasks', '--sort-tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-sorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 2)).toEqual(sliceLines(expected, 2)); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should overridden by cli flag: --no-sort-tasks', function(done) { - var opts = { cwd: path.join(baseDir, 't') }; - exec(gulp('--tasks', '--no-sort-tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-unsorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 2)).toEqual(sliceLines(expected, 2)); - expect(stderr).toEqual(''); - done(err); - } - }); - -}); diff --git a/test/config-flags-tasks-depth.js b/test/config-flags-tasks-depth.js deleted file mode 100644 index 68a09037..00000000 --- a/test/config-flags-tasks-depth.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); -var fs = require('fs'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/config/flags/tasksDepth'); -var expectedDir = path.join(__dirname, 'expected'); - -describe('config: flags.tasksDepth', function() { - - it('Should limit depth of task list when `flags.tasksDepth` is specified', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-depth4.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 2)).toEqual(sliceLines(expected, 2)); - expect(stderr).toEqual(''); - done(err); - } - }); - - it('Should overridden by cli flag: --tasks-depth', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--tasks', '--tasks-depth', '2'), opts, cb); - - function cb(err, stdout, stderr) { - var filepath = path.join(expectedDir, 'flags-tasks-depth2.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 2)).toEqual(sliceLines(expected, 2)); - expect(stderr).toEqual(''); - done(err); - } - }); -}); diff --git a/test/config-message-function.js b/test/config-message-function.js deleted file mode 100644 index 3a6eae5a..00000000 --- a/test/config-message-function.js +++ /dev/null @@ -1,490 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); -var fs = require('fs'); -var os = require('os'); - -var tildify = require('../lib/shared/tildify'); - -var baseDir = path.join(__dirname, 'fixtures/config/theming'); -var expectedDir = path.join(__dirname, 'expected/config/theming'); - -var eraseTime = require('./tool/erase-time'); -var eraseLapse = require('./tool/erase-lapse'); -var gulp = require('./tool/gulp-cmd'); - -describe('config: message function', function() { - - it('can change USAGE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'USAGE'); - var expected = fs.readFileSync(path.join(expectedDir, 'usage.txt'), 'utf8'); - - var opts = { cwd: cwd }; - exec(gulp('--help'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(expected); - done(err); - } - }); - - it('can change flag descriptions with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'flags'); - var expected = fs.readFileSync(path.join(expectedDir, 'flags.txt'), 'utf8'); - - var opts = { cwd: cwd }; - exec(gulp('--help'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(expected); - done(err); - } - }); - - it('can change DESCRIPTION with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'DESCRIPTION'); - var expected = '**DESCRIPTION**\n' + - '└── default\n'; - - var opts = { cwd: cwd }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(expected); - done(err); - } - }); - - it('can remove DESCRIPTION line output with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'DESCRIPTION/remove'); - var expected = '└── default\n'; - - var opts = { cwd: cwd }; - exec(gulp('--tasks'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(expected); - done(err); - } - }); - - it('can change DESCRIPTION for tasks-json with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'DESCRIPTION'); - var expected = JSON.stringify({ - label: '**DESCRIPTION**', - nodes: [{ - label: 'default', - type: 'task', - nodes: [], - }], - }) + '\n'; - - var opts = { cwd: cwd }; - exec(gulp('--tasks-json'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(expected); - done(err); - } - }); - - it('can change PRELOAD_BEFORE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'PRELOAD_BEFORE'); - var expected = 'PRELOADING **./preload**!\n'; - - var opts = { cwd: cwd }; - exec(gulp('--preload ./preload'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change PRELOAD_SUCCESS with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'PRELOAD_SUCCESS'); - var expected = 'PRELOADED **./preload**!\n'; - - var opts = { cwd: cwd }; - exec(gulp('--preload ./preload'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change LOADER_SUCCESS with .gulp.*', function(done) { - this.timeout(0); - - var cwd = path.join(baseDir, 'LOADER_SUCCESS'); - var expected = 'LOADED **@babel/register**!\n'; - - var opts = { cwd: cwd }; - exec(gulp('-f gulpfile.babel.js'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change NODE_FLAGS with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'NODE_FLAGS'); - var expected = 'RESPAWNED BY **--lazy**!\n'; - - var opts = { cwd: cwd }; - exec(gulp('--lazy'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change RESPAWNED with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'RESPAWNED'); - var expected = 'RESPAWN!\n'; - - var opts = { cwd: cwd }; - exec(gulp('--lazy'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change CWD_CHANGED with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'CWD_CHANGED'); - var expected = 'CHANGE CWD TO **' + cwd + '**\n'; - - var opts = { cwd: baseDir }; - exec(gulp('--cwd ' + cwd), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change GULPFILE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'GULPFILE'); - var expected = 'USING GULPFILE **abcxyz**\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change TASK_START with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'TASK_START'); - var expected = 'START **default**\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change TASK_STOP with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'TASK_STOP'); - var expected = 'STOP **default**\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseTime(stdout)).toEqual(expected); - done(err); - } - }); - - it('can change PRELOAD_FAILURE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'PRELOAD_FAILURE'); - var expected = 'FAILED TO PRELOAD **null-module**\n' - - var opts = { cwd: cwd }; - exec(gulp('--preload null-module'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(eraseLapse(eraseTime(stdout))).toEqual(expected); - done(err); - } - }); - - it('can change LOADER_FAILURE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'LOADER_FAILURE'); - var expected = 'FAIL TO LOAD **coffeescript/register**\n'; - - var opts = { cwd: cwd }; - exec(gulp('-f gulpfile.coffee'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stderr).not.toEqual(''); - expect(eraseTime(stdout)).toEqual(expected); - done(); - } - }); - - it('can change TASK_SYNC with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'TASK_SYNC'); - var gulpfile = tildify(path.join(cwd, 'gulpfile.js')); - var expected = 'Using gulpfile ' + gulpfile + '\n' + - 'Starting \'default\'...\n' + - 'TASK **default** DID NOT COMPLETE\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stderr).toEqual(''); - expect(eraseTime(stdout)).toEqual(expected); - done(); - } - }); - - it('can change ARGV_ERROR with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'ARGV_ERROR'); - var expected = fs.readFileSync(path.join(expectedDir, 'bad-flag.txt'), 'utf8'); - - var opts = { cwd: cwd }; - exec(gulp('-f'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual(expected); - done(); - } - }); - - it('can change MISSING_GULP with .gulp.*', function(done) { - var dir = path.join(baseDir, 'MISSING_GULP'); - var cwd = os.tmpdir(); - fs.copyFileSync(path.join(dir, '.gulp.js'), path.join(cwd, '.gulp.js')); - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - if (os.platform() === 'darwin') { - cwd = path.join('/private', cwd); - } - var expected = 'GULP NOT FOUND IN **' + cwd + '**\n'; - - function cb(err, stdout, stderr) { - try { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual(expected); - done(); - } finally { - fs.unlinkSync(path.join(cwd, '.gulp.js')); - } - } - }); - - it('can change MISSING_NODE_MODULES with .gulp.*', function(done) { - var dir = path.join(baseDir, 'MISSING_NODE_MODULES'); - var cwd = os.tmpdir(); - fs.copyFileSync(path.join(dir, '.gulp.js'), path.join(cwd, '.gulp.js')); - fs.copyFileSync(path.join(dir, 'package.json'), path.join(cwd, 'package.json')); - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - if (os.platform() === 'darwin') { - cwd = path.join('/private', cwd); - } - var expected = 'LOCAL MODULE NOT FOUND **' + cwd + '**\n'; - - function cb(err, stdout, stderr) { - try { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual(expected); - done(); - } finally { - fs.unlinkSync(path.join(cwd, '.gulp.js')); - fs.unlinkSync(path.join(cwd, 'package.json')); - } - } - }); - - it('can change MISSING_GULPFILE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'MISSING_GULPFILE'); - var expected = 'NO GULPFILE\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual(expected); - done(); - } - }); - - it('can change UNSUPPORTED_GULP_VERSION with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'UNSUPPORTED_GULP_VERSION'); - var expected = 'BAD GULP VERSION **1.2.3**\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(eraseTime(stderr)).toEqual(expected); - done(); - } - }); - - it('can change TASK_FAILURE with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'TASK_FAILURE'); - var expectedStderr = 'TASK FAILURE: **default**\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual(expectedStderr); - done(); - } - }); - - it('can change TASK_ERROR with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'TASK_ERROR'); - var expectedStderr = '**TASK ERROR**\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual(expectedStderr); - done(); - } - }); - - it('can change TASK_MISSING with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'TASK_MISSING'); - var expectedStdout = 'Using gulpfile!\n'; - var expectedStderr = 'TASK IS NOT FOUND: **defaults** SIMILAR ##default##'; - - var opts = { cwd: cwd }; - exec(gulp('defaults'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(eraseTime(stderr)).toMatch(expectedStderr); - expect(eraseTime(stdout)).toEqual(expectedStdout); - done(); - } - }); - - // Would need to hook gulp to test this - it.skip('can change EXEC_ERROR with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'EXEC_ERROR'); - var expected = 'FAIL TO RUN\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(eraseTime(stderr)).toEqual(expected); - expect(stdout).toEqual(''); - done(); - } - }); - - it('can change COMPLETION_TYPE_MISSING with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'COMPLETION_TYPE_MISSING'); - var expected = 'NO COMPLETION TYPE'; - - var opts = { cwd: cwd }; - exec(gulp('--completion'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stderr).toMatch(expected); - expect(stdout).toEqual(''); - done(); - } - }); - - it('can change COMPLETION_TYPE_UNKNOWN with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'COMPLETION_TYPE_UNKNOWN'); - var expected = 'GULP COMPLETION TYPE **xxx** IS NOT FOUND\n'; - - var opts = { cwd: cwd }; - exec(gulp('--completion=xxx'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(expected); - done(); - } - }); - - it('can change GULPLOG_DEPRECATED with .gulp.*', function(done) { - var cwd = path.join(baseDir, 'GULPLOG_DEPRECATED'); - var expected = 'GULPLOG V1 IS DEPRECATED\n'; - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual(expected); - done(); - } - }); -}); diff --git a/test/config.js b/test/config.js new file mode 100644 index 00000000..e2ce6c48 --- /dev/null +++ b/test/config.js @@ -0,0 +1,63 @@ +'use strict'; + +var expect = require('expect'); +var path = require('path'); +var fs = require('fs'); + +var skipLines = require('gulp-test-tools').skipLines; +var eraseTime = require('gulp-test-tools').eraseTime; +var runner = require('gulp-test-tools').gulpRunner; + +var fixturesDir = path.join(__dirname, 'fixtures', 'config'); +var expectedDir = path.join(__dirname, 'expected', 'config'); + +describe('gulp configuration', function() { + + it('Should configure with a .gulp.* file in cwd', function(done) { + runner({ verbose: false }) + .basedir(fixturesDir) + .chdir('foo/bar') + .gulp('--tasks') + .run(cb); + + function cb(err, stdout) { + var expected = fs.readFileSync(path.join(expectedDir, 'output0.txt'), + 'utf-8'); + stdout = eraseTime(stdout); + expect(stdout).toEqual(expected); + done(err); + } + }); + + it('Should configure with a .gulp.* file in cwd found up', function(done) { + runner({ verbose: false }) + .basedir(fixturesDir) + .chdir('foo/bar/baz') + .gulp('--tasks') + .run(cb); + + function cb(err, stdout) { + var expected = fs.readFileSync(path.join(expectedDir, 'output0.txt'), + 'utf-8'); + stdout = eraseTime(skipLines(stdout, 1)); + expect(stdout).toEqual(expected); + done(err); + } + }); + + it('Should configure with a .gulp.* file in cwd by --cwd', function(done) { + runner({ verbose: false }) + .basedir(fixturesDir) + .chdir('qux') + .gulp('--tasks', '--gulpfile ../foo/bar/gulpfile.js', '--cwd .') + .run(cb); + + function cb(err, stdout) { + var expected = fs.readFileSync(path.join(expectedDir, 'output1.txt'), + 'utf-8'); + stdout = eraseTime(stdout); + expect(stdout).toEqual(expected); + done(err); + } + }); +}); diff --git a/test/esm.js b/test/esm.js deleted file mode 100644 index 784a4036..00000000 --- a/test/esm.js +++ /dev/null @@ -1,88 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var fs = require('fs'); -var path = require('path'); -var semver = require('semver'); -var os = require('os'); - -var baseDir = path.join(__dirname, '..'); -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var expectedDir = path.join(__dirname, 'expected'); - -function shouldSkip() { - switch (os.platform()) { - case 'win32': { - return semver.satisfies(process.version, '^11.2.0') || - (process.env.CI && semver.satisfies(process.version, '10.x.x')); - } - case 'darwin': { - return semver.satisfies(process.version, '>=11.0.0 <11.11.0'); - } - case 'linux': { - return semver.satisfies(process.version, '>=11.2.0 <11.4.0'); - } - } - return semver.satisfies(process.version, '12.8.x || >=12.11.0 <12.18.0 || >=13.0.0 <13.8.0'); -} - -describe('ESM', function() { - - it('prints the task list', function(done) { - if (shouldSkip()) { - this.skip(); - } - - var options = '--tasks --sort-tasks --gulpfile ./test/fixtures/gulpfiles/gulpfile.mjs'; - var trailingLines = 1; - if (!semver.satisfies(process.version, '^12.17.0 || >=13.2.0')) { - options += ' --experimental-modules'; - trailingLines += 2; - } - - var opts = { cwd: baseDir }; - exec(gulp(options), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - if (!semver.satisfies(process.version, '^12.20.0 || >=13.14.0')) { - expect(stderr).toMatch('ExperimentalWarning: The ESM module loader is experimental.\n'); - } else { - expect(stderr).toEqual(''); - } - var filepath = path.join(expectedDir, 'esm.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, trailingLines)).toEqual(expected); - done(err); - } - }); - - it('prints the task list (top-level await)', function(done) { - if (shouldSkip()) { - this.skip(); - } - - if (semver.satisfies(process.version, '10 || 12')) { - this.skip(); - } - - var options = '--tasks --sort-tasks --gulpfile ./test/fixtures/gulpfiles/gulpfile-tla.mjs'; - var trailingLines = 1; - - var opts = { cwd: baseDir }; - exec(gulp(options), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'esm.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, trailingLines)).toEqual(expected); - done(err); - } - }); - -}); diff --git a/test/execution-errors.js b/test/execution-errors.js deleted file mode 100644 index 7b2fd1ec..00000000 --- a/test/execution-errors.js +++ /dev/null @@ -1,174 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); -var os = require('os'); -var fs = require('fs'); - -var tildify = require('../lib/shared/tildify'); - -var eraseTime = require('./tool/erase-time'); -var eraseLapse = require('./tool/erase-lapse'); -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -describe('execution error', function() { - - it('should output an error if a task is not defined', function(done) { - var opts = { cwd: path.join(__dirname, './fixtures/gulpfiles') }; - exec(gulp('a'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(eraseTime(stdout)).toMatch('Using gulpfile '); - expect(eraseTime(stderr)).toEqual( - 'Task never defined: a\n' + - 'To list available tasks, try running: gulp --tasks\n'); - done(); - } - }); - - it('should output an error if a task is not defined but a similar task is found', function(done) { - var opts = { cwd: path.join(__dirname, './fixtures/gulpfiles') }; - exec(gulp('test0'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(eraseTime(stdout)).toMatch('Using gulpfile '); - expect(eraseTime(stderr)).toEqual( - 'Task never defined: test0 - did you mean? test1, test2, test3, test4, test5, test6, test7, test8\n' + - 'To list available tasks, try running: gulp --tasks\n'); - done(); - } - }); - - it('should output an error if gulp version is unsupported', function(done) { - var opts = { cwd: path.join(__dirname, './fixtures/errors/bad-gulp-version') }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(eraseTime(stdout)).toEqual(''); - expect(eraseTime(stderr)).toEqual('Unsupported gulp version 1.2.3\n'); - done(); - } - }); - - it('should output an error if gulp is not found (npm)', function(done) { - var opts = { cwd: os.tmpdir() }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(sliceLines(stderr, 0, 1)).toMatch('Local gulp not found in '); - expect(sliceLines(stderr, 1, 2)).toEqual('Try running: npm install gulp'); - done(); - } - }); - - it('should output an error if gulp is not found (yarn)', function(done) { - var cwd = os.tmpdir(); - var yarnOrig= path.join(__dirname, 'fixtures/errors/yarn/yarn.lock'); - var yarnLock = path.join(cwd, 'yarn.lock'); - - fs.copyFileSync(yarnOrig, yarnLock); - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - try { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(sliceLines(stderr, 0, 1)).toMatch('Local gulp not found in '); - expect(sliceLines(stderr, 1, 2)).toEqual('Try running: yarn add gulp'); - done(); - } finally { - fs.unlinkSync(yarnLock); - } - } - }); - - it('should output an error if local modules are not found (npm)', function(done) { - var cwd = os.tmpdir(); - var pkgOrig = path.join(__dirname, 'fixtures/errors/package.json'); - var pkgJson = path.join(cwd, 'package.json'); - - fs.copyFileSync(pkgOrig, pkgJson); - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - try { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(sliceLines(stderr, 0, 1)).toMatch('Local modules not found in '); - expect(sliceLines(stderr, 1, 2)).toEqual('Try running: npm install'); - done(); - } finally { - fs.unlinkSync(pkgJson); - } - } - }); - - it('should output an error if local modules are not found (yarn)', function(done) { - var cwd = os.tmpdir(); - var pkgOrig = path.join(__dirname, 'fixtures/errors/package.json'); - var pkgJson = path.join(cwd, 'package.json'); - var yarnOrig= path.join(__dirname, 'fixtures/errors/yarn/yarn.lock'); - var yarnLock = path.join(cwd, 'yarn.lock'); - - fs.copyFileSync(pkgOrig, pkgJson); - fs.copyFileSync(yarnOrig, yarnLock); - - var opts = { cwd: cwd }; - exec(gulp(), opts, cb); - - function cb(err, stdout, stderr) { - try { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(sliceLines(stderr, 0, 1)).toMatch('Local modules not found in '); - expect(sliceLines(stderr, 1, 2)).toEqual('Try running: yarn install'); - done(); - } finally { - fs.unlinkSync(pkgJson); - fs.unlinkSync(yarnLock); - } - } - }); - - it('should log a same error once', function(done) { - var dir = path.join(__dirname, 'fixtures/gulpfiles'); - var gulpfileName = 'gulpfile-dedup-errorlog.js'; - - exec(gulp( - '--gulpfile', gulpfileName - ), { cwd: dir }, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - expect(sliceLines(stdout)).toEqual( - 'Using gulpfile ' + tildify(path.join(dir, gulpfileName)) + '\n' + - 'Starting \'default\'...\n' + - 'Starting \'b\'...\n' + - 'Starting \'a\'...\n' + - ''); - stderr = eraseLapse(eraseTime(stderr)).split(/[\r\n]+/); - var n = stderr.length; - expect(stderr[0]).toEqual('\'a\' errored after ?'); - expect(stderr[1]).toEqual('Error: Task \'a\' failed!'); - expect(stderr[n - 3]).toEqual('\'b\' errored after ?'); - expect(stderr[n - 2]).toEqual('\'default\' errored after ?'); - expect(stderr[n - 1]).toEqual(''); - done(); - } - }); -}); diff --git a/test/expected/config/output2.txt b/test/expected/config/output2.txt deleted file mode 100644 index a0d45083..00000000 --- a/test/expected/config/output2.txt +++ /dev/null @@ -1,2 +0,0 @@ -DESCRIPTION BY .gulp.babel.js in directory foo/bar/quux -└── default diff --git a/test/expected/config/theming/bad-flag.txt b/test/expected/config/theming/bad-flag.txt deleted file mode 100644 index 5d37e6fa..00000000 --- a/test/expected/config/theming/bad-flag.txt +++ /dev/null @@ -1,41 +0,0 @@ -**Not enough arguments following: f** - -Usage: gulp [options] tasks - -Options: - -h, --help Show this help. [boolean] - -v, --version Print the global and local gulp versions.[boolean] - --preload Will preload a module before running the gulpfile. - This is useful for transpilers but also has other - applications. [string] - -f, --gulpfile Manually set path of gulpfile. Useful if you have - multiple gulpfiles. This will set the CWD to the - gulpfile directory as well. [string] - --cwd Manually set the CWD. The search for the gulpfile, - as well as the relativity of all requires will be - from here. [string] - -T, --tasks Print the task dependency tree for the loaded - gulpfile. [boolean] - --tasks-simple Print a plaintext list of tasks for the loaded - gulpfile. [boolean] - --tasks-json Print the task dependency tree, in JSON format, - for the loaded gulpfile. - --tasks-depth, --depth Specify the depth of the task dependency tree. - [number] - --compact-tasks Reduce the output of task dependency tree by - printing only top tasks and their child tasks. - [boolean] - --sort-tasks Will sort top tasks of task dependency tree. - [boolean] - --color Will force gulp and gulp plugins to display - colors, even when no color support is detected. - [boolean] - --no-color Will force gulp and gulp plugins to not display - colors, even when color support is detected. - [boolean] - -S, --silent Suppress all gulp logging. [boolean] - --continue Continue execution of tasks upon failure.[boolean] - --series Run tasks given on the CLI in series (the default - is parallel). [boolean] - -L, --log-level Set the loglevel. -L for least verbose and -LLLL - for most verbose. -LLL is default. [count] diff --git a/test/expected/config/theming/flags.txt b/test/expected/config/theming/flags.txt deleted file mode 100644 index a9da43fc..00000000 --- a/test/expected/config/theming/flags.txt +++ /dev/null @@ -1,18 +0,0 @@ -Options: - -h, --help **HELP** [boolean] - -v, --version **VERSION** [boolean] - --preload **PRELOAD** [string] - -f, --gulpfile **GULPFILE** [string] - --cwd **CWD** [string] - -T, --tasks **TASKS** [boolean] - --tasks-simple **TASKS SIMPLE** [boolean] - --tasks-json **TASKS JSON** - --tasks-depth, --depth **TASKS DEPTH** [number] - --compact-tasks **COMPACT TASKS** [boolean] - --sort-tasks **SORT_TASKS** [boolean] - --color **COLOR** [boolean] - --no-color **NO COLOR** [boolean] - -S, --silent **SILENT** [boolean] - --continue **CONTINUE** [boolean] - --series **SERIES** [boolean] - -L, --log-level **LOG LEVEL** [count] diff --git a/test/expected/config/theming/usage.txt b/test/expected/config/theming/usage.txt deleted file mode 100644 index b03f78bd..00000000 --- a/test/expected/config/theming/usage.txt +++ /dev/null @@ -1,39 +0,0 @@ -GULP USAGE - -Options: - -h, --help Show this help. [boolean] - -v, --version Print the global and local gulp versions.[boolean] - --preload Will preload a module before running the gulpfile. - This is useful for transpilers but also has other - applications. [string] - -f, --gulpfile Manually set path of gulpfile. Useful if you have - multiple gulpfiles. This will set the CWD to the - gulpfile directory as well. [string] - --cwd Manually set the CWD. The search for the gulpfile, - as well as the relativity of all requires will be - from here. [string] - -T, --tasks Print the task dependency tree for the loaded - gulpfile. [boolean] - --tasks-simple Print a plaintext list of tasks for the loaded - gulpfile. [boolean] - --tasks-json Print the task dependency tree, in JSON format, - for the loaded gulpfile. - --tasks-depth, --depth Specify the depth of the task dependency tree. - [number] - --compact-tasks Reduce the output of task dependency tree by - printing only top tasks and their child tasks. - [boolean] - --sort-tasks Will sort top tasks of task dependency tree. - [boolean] - --color Will force gulp and gulp plugins to display - colors, even when no color support is detected. - [boolean] - --no-color Will force gulp and gulp plugins to not display - colors, even when color support is detected. - [boolean] - -S, --silent Suppress all gulp logging. [boolean] - --continue Continue execution of tasks upon failure.[boolean] - --series Run tasks given on the CLI in series (the default - is parallel). [boolean] - -L, --log-level Set the loglevel. -L for least verbose and -LLLL - for most verbose. -LLL is default. [count] diff --git a/test/expected/copy-tree/copy-tree-compact.json b/test/expected/copy-tree/copy-tree-compact.json deleted file mode 100644 index 113473a4..00000000 --- a/test/expected/copy-tree/copy-tree-compact.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "label": "Label of Top node", - "nodes": [ - { - "label": "Label of node 1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1", - "branch": false, - "nodes": [] - }, - { - "label": "Label of node 2.2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3", - "nodes": [ - { - "label": "Label of node 3.1", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3.2", - "nodes": [] - } - ] - } - ] -} diff --git a/test/expected/copy-tree/copy-tree-depth-1.json b/test/expected/copy-tree/copy-tree-depth-1.json deleted file mode 100644 index 1f10a3f7..00000000 --- a/test/expected/copy-tree/copy-tree-depth-1.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "label": "Label of Top node", - "nodes": [ - { - "label": "Label of node 1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 3", - "nodes": [] - } - ] -} diff --git a/test/expected/copy-tree/copy-tree-depth-2.json b/test/expected/copy-tree/copy-tree-depth-2.json deleted file mode 100644 index a43b47f1..00000000 --- a/test/expected/copy-tree/copy-tree-depth-2.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "label": "Label of Top node", - "nodes": [ - { - "label": "Label of node 1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1", - "branch": false, - "nodes": [] - }, - { - "label": "Label of node 2.2", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3", - "nodes": [ - { - "label": "Label of node 3.1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 3.2", - "nodes": [] - } - ] - } - ] -} diff --git a/test/expected/copy-tree/copy-tree-depth-3.json b/test/expected/copy-tree/copy-tree-depth-3.json deleted file mode 100644 index 29e2acdc..00000000 --- a/test/expected/copy-tree/copy-tree-depth-3.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "label": "Label of Top node", - "nodes": [ - { - "label": "Label of node 1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1", - "branch": false, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3", - "nodes": [ - { - "label": "Label of node 3.1", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3.2", - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - } - ] - } - ] -} diff --git a/test/expected/copy-tree/copy-tree-depth-4.json b/test/expected/copy-tree/copy-tree-depth-4.json deleted file mode 100644 index acfb240c..00000000 --- a/test/expected/copy-tree/copy-tree-depth-4.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "label": "Label of Top node", - "nodes": [ - { - "label": "Label of node 1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1", - "branch": false, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3", - "nodes": [ - { - "label": "Label of node 3.1", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [ - { - "label": "Label of node 2.1.1.1", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3.2", - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [ - { - "label": "Label of node 2.1.2.1", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - } - ] - } - ] -} diff --git a/test/expected/esm.txt b/test/expected/esm.txt deleted file mode 100644 index e50b9893..00000000 --- a/test/expected/esm.txt +++ /dev/null @@ -1,3 +0,0 @@ -gulp-cli/test/fixtures/gulpfiles -├── exported -└── registered diff --git a/test/expected/flags-help.txt b/test/expected/flags-help.txt index bdf95bbe..009a10b6 100644 --- a/test/expected/flags-help.txt +++ b/test/expected/flags-help.txt @@ -2,39 +2,19 @@ Usage: gulp [options] tasks Options: - -h, --help Show this help. [boolean] - -v, --version Print the global and local gulp versions.[boolean] - --preload Will preload a module before running the gulpfile. - This is useful for transpilers but also has other - applications. [string] - -f, --gulpfile Manually set path of gulpfile. Useful if you have - multiple gulpfiles. This will set the CWD to the - gulpfile directory as well. [string] - --cwd Manually set the CWD. The search for the gulpfile, - as well as the relativity of all requires will be - from here. [string] - -T, --tasks Print the task dependency tree for the loaded - gulpfile. [boolean] - --tasks-simple Print a plaintext list of tasks for the loaded - gulpfile. [boolean] - --tasks-json Print the task dependency tree, in JSON format, - for the loaded gulpfile. - --tasks-depth, --depth Specify the depth of the task dependency tree. - [number] - --compact-tasks Reduce the output of task dependency tree by - printing only top tasks and their child tasks. - [boolean] - --sort-tasks Will sort top tasks of task dependency tree. - [boolean] - --color Will force gulp and gulp plugins to display - colors, even when no color support is detected. - [boolean] - --no-color Will force gulp and gulp plugins to not display - colors, even when color support is detected. - [boolean] - -S, --silent Suppress all gulp logging. [boolean] - --continue Continue execution of tasks upon failure.[boolean] - --series Run tasks given on the CLI in series (the default - is parallel). [boolean] - -L, --log-level Set the loglevel. -L for least verbose and -LLLL - for most verbose. -LLL is default. [count] + --help, -h Show this help. [boolean] + --version, -v Print the global and local gulp versions. [boolean] + --require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. [string] + --gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string] + --cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. [string] + --verify Will verify plugins referenced in project's package.json against the plugins blacklist. + --tasks, -T Print the task dependency tree for the loaded gulpfile. [boolean] + --depth Specify the depth of the task dependency tree. + --tasks-simple Print a plaintext list of tasks for the loaded gulpfile. [boolean] + --tasks-json Print the task dependency tree, in JSON format, for the loaded gulpfile. + --color Will force gulp and gulp plugins to display colors, even when no color support is detected. [boolean] + --no-color Will force gulp and gulp plugins to not display colors, even when color support is detected. [boolean] + --silent, -S Suppress all gulp logging. [boolean] + --continue Continue execution of tasks upon failure. [boolean] + --log-level, -L Set the loglevel. -L for least verbose and -LLLL for most verbose. -LLL is default. [count] + diff --git a/test/expected/flags-tasks-compact.txt b/test/expected/flags-tasks-compact.txt deleted file mode 100644 index d15def9b..00000000 --- a/test/expected/flags-tasks-compact.txt +++ /dev/null @@ -1,16 +0,0 @@ -Working directory changed to gulp-cli/test/fixtures/gulpfiles -gulp-cli/test/fixtures/gulpfiles -├─┬ taskC -│ └─┬ -│ ├── func1 -│ └── func2 -├─┬ taskB -│ └─┬ -│ ├── func3 -│ └── taskC -└─┬ default - └─┬ - ├── taskC - └─┬ - ├── taskB - └── func4 diff --git a/test/expected/flags-tasks-depth1.txt b/test/expected/flags-tasks-depth1.txt deleted file mode 100644 index d973a446..00000000 --- a/test/expected/flags-tasks-depth1.txt +++ /dev/null @@ -1,4 +0,0 @@ -gulp-cli/test/fixtures/gulpfiles -├── taskC -├── taskB -└── default diff --git a/test/expected/flags-tasks-depth2.txt b/test/expected/flags-tasks-depth2.txt deleted file mode 100644 index 3edbdf74..00000000 --- a/test/expected/flags-tasks-depth2.txt +++ /dev/null @@ -1,8 +0,0 @@ -Working directory changed to gulp-cli/test/fixtures/gulpfiles -gulp-cli/test/fixtures/gulpfiles -├─┬ taskC -│ └── -├─┬ taskB -│ └── -└─┬ default - └── diff --git a/test/expected/flags-tasks-depth4.txt b/test/expected/flags-tasks-depth4.txt deleted file mode 100644 index 6d79eb1e..00000000 --- a/test/expected/flags-tasks-depth4.txt +++ /dev/null @@ -1,18 +0,0 @@ -Working directory changed to gulp-cli/test/fixtures/gulpfiles -gulp-cli/test/fixtures/gulpfiles -├─┬ taskC -│ └─┬ -│ ├── func1 -│ └── func2 -├─┬ taskB -│ └─┬ -│ ├── func3 -│ └─┬ taskC -│ └── -└─┬ default - └─┬ - ├─┬ taskC - │ └── - └─┬ - ├── taskB - └── func4 diff --git a/test/expected/flags-tasks-json.json b/test/expected/flags-tasks-json.json index 2bbe3f2c..d22a0e65 100644 --- a/test/expected/flags-tasks-json.json +++ b/test/expected/flags-tasks-json.json @@ -1 +1 @@ -{"label":"gulp-cli/test/fixtures/gulpfiles","nodes":[{"label":"test1","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"test5","nodes":[],"type":"task"},{"label":"test6","nodes":[],"type":"task"},{"label":"test7","nodes":[],"type":"task"},{"label":"test8","nodes":[],"type":"task"},{"label":"default","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]}]} +{"label":"gulp-cli/test/fixtures/gulpfiles","nodes":[{"label":"test1","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"default","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"test1","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"","type":"function","branch":true,"nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]}]} diff --git a/test/expected/flags-tasks-simple.txt b/test/expected/flags-tasks-simple.txt index 753dbd5d..45085a74 100644 --- a/test/expected/flags-tasks-simple.txt +++ b/test/expected/flags-tasks-simple.txt @@ -2,8 +2,4 @@ test1 test2 test3 test4 -test5 -test6 -test7 -test8 default diff --git a/test/expected/flags-tasks-sorted.txt b/test/expected/flags-tasks-sorted.txt deleted file mode 100644 index 1bdc4cfd..00000000 --- a/test/expected/flags-tasks-sorted.txt +++ /dev/null @@ -1,28 +0,0 @@ -Working directory changed to gulp-cli/test/fixtures/gulpfiles -gulp-cli/test/fixtures/gulpfiles -├─┬ default -│ └─┬ -│ ├─┬ taskC -│ │ └─┬ -│ │ ├── func1 -│ │ └── func2 -│ └─┬ -│ ├─┬ taskB -│ │ └─┬ -│ │ ├── func3 -│ │ └─┬ taskC -│ │ └─┬ -│ │ ├── func1 -│ │ └── func2 -│ └── func4 -├─┬ taskB -│ └─┬ -│ ├── func3 -│ └─┬ taskC -│ └─┬ -│ ├── func1 -│ └── func2 -└─┬ taskC - └─┬ - ├── func1 - └── func2 diff --git a/test/expected/flags-tasks-unsorted.txt b/test/expected/flags-tasks-unsorted.txt deleted file mode 100644 index edd85682..00000000 --- a/test/expected/flags-tasks-unsorted.txt +++ /dev/null @@ -1,28 +0,0 @@ -Working directory changed to gulp-cli/test/fixtures/gulpfiles -gulp-cli/test/fixtures/gulpfiles -├─┬ taskC -│ └─┬ -│ ├── func1 -│ └── func2 -├─┬ taskB -│ └─┬ -│ ├── func3 -│ └─┬ taskC -│ └─┬ -│ ├── func1 -│ └── func2 -└─┬ default - └─┬ - ├─┬ taskC - │ └─┬ - │ ├── func1 - │ └── func2 - └─┬ - ├─┬ taskB - │ └─┬ - │ ├── func3 - │ └─┬ taskC - │ └─┬ - │ ├── func1 - │ └── func2 - └── func4 diff --git a/test/expected/flags-tasks.txt b/test/expected/flags-tasks.txt index 5100075b..cdfe8041 100644 --- a/test/expected/flags-tasks.txt +++ b/test/expected/flags-tasks.txt @@ -20,11 +20,7 @@ gulp-cli/test/fixtures/gulpfiles ├─┬ test3 │ └─┬ │ └── described -├─┬ test4 -│ └─┬ -│ ├── errorFunction -│ └── anon -├── test5 -├── test6 -├── test7 -└── test8 +└─┬ test4 + └─┬ + ├── errorFunction + └── anon diff --git a/test/expected/tasks-as-exports.txt b/test/expected/tasks-as-exports.txt index dd574b4f..8c825148 100644 --- a/test/expected/tasks-as-exports.txt +++ b/test/expected/tasks-as-exports.txt @@ -1,20 +1,7 @@ gulp-cli/test/fixtures/gulpfiles ├── build ├── clean -├─┬ dist -│ └─┬ -│ ├── clean -│ └── build -├── f-test -├─┬ p -│ └─┬ -│ ├── p1 -│ └── p2 -├─┬ p-test -│ └─┬ -│ ├── p1 -│ └── p2 -└─┬ s-test +└─┬ dist └─┬ ├── clean └── build diff --git a/test/expected/with-desc-and-flags.txt b/test/expected/with-desc-and-flags.txt index 34e85d2c..6d65313d 100644 --- a/test/expected/with-desc-and-flags.txt +++ b/test/expected/with-desc-and-flags.txt @@ -1,6 +1,6 @@ gulp-cli/test/fixtures ├─┬ build Build all the things! -│ │ --dev +│ │ --dev …un-minified │ │ --production …compressed into single bundle │ └─┬ │ ├── clean diff --git a/test/exports-as-tasks.js b/test/exports-as-tasks.js index 81bee75e..708287ac 100644 --- a/test/exports-as-tasks.js +++ b/test/exports-as-tasks.js @@ -1,14 +1,12 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; var fs = require('fs'); var path = require('path'); +var skipLines = require('gulp-test-tools').skipLines; +var eraseTime = require('gulp-test-tools').eraseTime; +var runner = require('gulp-test-tools').gulpRunner; -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); var expectedDir = path.join(__dirname, 'expected'); // Long timeout is required because parse time is slow @@ -16,21 +14,17 @@ describe('exports as tasks', function() { this.timeout(0); it('prints the task list', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--sort-tasks', - '--gulpfile', './test/fixtures/gulpfiles/gulpfile-exports.babel.js' - ), opts, cb); + runner({ verbose: false }) + .gulp('--tasks', + '--gulpfile ./test/fixtures/gulpfiles/gulpfile-exports.babel.js') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { var filepath = path.join(expectedDir, 'tasks-as-exports.txt'); var expected = fs.readFileSync(filepath, 'utf-8'); - // Remove babel/register lines - expect(sliceLines(stdout, 2)).toEqual(expected); - done(err); + stdout = eraseTime(skipLines(stdout, 2)); + expect(stdout).toEqual(expected); + done(); } }); diff --git a/test/fixtures/.babelrc b/test/fixtures/.babelrc new file mode 100644 index 00000000..c13c5f62 --- /dev/null +++ b/test/fixtures/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/test/fixtures/.gulp.js b/test/fixtures/.gulp.js deleted file mode 100644 index c2ca66b9..00000000 --- a/test/fixtures/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.DESCRIPTION) { - return "gulp-cli/test/fixtures"; - } - } -}; diff --git a/test/fixtures/.gulp.json b/test/fixtures/.gulp.json new file mode 100644 index 00000000..6aad6e7f --- /dev/null +++ b/test/fixtures/.gulp.json @@ -0,0 +1,3 @@ +{ + "description" : "gulp-cli/test/fixtures" +} diff --git a/test/fixtures/config/flags/compactTasks/f/.gulp.js b/test/fixtures/config/flags/compactTasks/f/.gulp.js deleted file mode 100644 index 9fef64e2..00000000 --- a/test/fixtures/config/flags/compactTasks/f/.gulp.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - gulpfile: '../../../../gulpfiles/gulpfile-4.js', - flags: { - compactTasks: false, - }, -}; diff --git a/test/fixtures/config/flags/compactTasks/t/.gulp.js b/test/fixtures/config/flags/compactTasks/t/.gulp.js deleted file mode 100644 index 8ac27e43..00000000 --- a/test/fixtures/config/flags/compactTasks/t/.gulp.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - gulpfile: '../../../../gulpfiles/gulpfile-4.js', - flags: { - compactTasks: true, - }, -}; diff --git a/test/fixtures/config/flags/continue/f/.gulp.js b/test/fixtures/config/flags/continue/f/.gulp.js deleted file mode 100644 index 6edb0159..00000000 --- a/test/fixtures/config/flags/continue/f/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - continue: false - } -}; diff --git a/test/fixtures/config/flags/continue/f/gulpfile.js b/test/fixtures/config/flags/continue/f/gulpfile.js deleted file mode 100644 index 1ea100cf..00000000 --- a/test/fixtures/config/flags/continue/f/gulpfile.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function err(done) { - done(new Error('Error!')); -} - -function next(done) { - done(); -} - -gulp.task('default', gulp.series(err, next)); diff --git a/test/fixtures/config/flags/continue/t/.gulp.js b/test/fixtures/config/flags/continue/t/.gulp.js deleted file mode 100644 index ed371532..00000000 --- a/test/fixtures/config/flags/continue/t/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - continue: true - } -}; diff --git a/test/fixtures/config/flags/continue/t/gulpfile.js b/test/fixtures/config/flags/continue/t/gulpfile.js deleted file mode 100644 index 1ea100cf..00000000 --- a/test/fixtures/config/flags/continue/t/gulpfile.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function err(done) { - done(new Error('Error!')); -} - -function next(done) { - done(); -} - -gulp.task('default', gulp.series(err, next)); diff --git a/test/fixtures/config/flags/gulpfile/autoload-fail/.gulp.js b/test/fixtures/config/flags/gulpfile/autoload-fail/.gulp.js deleted file mode 100644 index ecfc61d3..00000000 --- a/test/fixtures/config/flags/gulpfile/autoload-fail/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - gulpfile: "./other_dir/gulpfile.coffee" -}; diff --git a/test/fixtures/config/flags/gulpfile/autoload-fail/other_dir/gulpfile.coffee b/test/fixtures/config/flags/gulpfile/autoload-fail/other_dir/gulpfile.coffee deleted file mode 100644 index 1f8b8541..00000000 --- a/test/fixtures/config/flags/gulpfile/autoload-fail/other_dir/gulpfile.coffee +++ /dev/null @@ -1 +0,0 @@ -console.log 'hello' diff --git a/test/fixtures/config/flags/gulpfile/autoload/.gulp.js b/test/fixtures/config/flags/gulpfile/autoload/.gulp.js deleted file mode 100644 index b307baf1..00000000 --- a/test/fixtures/config/flags/gulpfile/autoload/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - gulpfile: "other_folder/gulpfile-exports.babel.js" -}; diff --git a/test/fixtures/config/flags/gulpfile/autoload/other_folder/gulpfile-exports.babel.js b/test/fixtures/config/flags/gulpfile/autoload/other_folder/gulpfile-exports.babel.js deleted file mode 100644 index 08520ff6..00000000 --- a/test/fixtures/config/flags/gulpfile/autoload/other_folder/gulpfile-exports.babel.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -import gulp from 'gulp'; - -export function clean(done) { console.log('clean!'); done(); }; -export function build(done) { console.log('build!'); done(); }; -export const string = 'no function'; -export const dist = gulp.series(clean, build); diff --git a/test/fixtures/config/flags/gulpfile/cwd/.gulp.js b/test/fixtures/config/flags/gulpfile/cwd/.gulp.js deleted file mode 100644 index 3ff2eb25..00000000 --- a/test/fixtures/config/flags/gulpfile/cwd/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - gulpfile: "../is/here/gulpfile-by-cwd-cfg.js" -}; diff --git a/test/fixtures/config/flags/gulpfile/cwd/findup/.gitkeep b/test/fixtures/config/flags/gulpfile/cwd/findup/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/config/flags/gulpfile/is/here/gulpfile-by-cwd-cfg.js b/test/fixtures/config/flags/gulpfile/is/here/gulpfile-by-cwd-cfg.js deleted file mode 100644 index 61b4199a..00000000 --- a/test/fixtures/config/flags/gulpfile/is/here/gulpfile-by-cwd-cfg.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log('This gulpfile : ' + __filename); - console.log('The current directory : ' + process.cwd()); - done(); -}); diff --git a/test/fixtures/config/flags/gulpfile/is/here/gulpfile-by-prj-cfg.js b/test/fixtures/config/flags/gulpfile/is/here/gulpfile-by-prj-cfg.js deleted file mode 100644 index 61b4199a..00000000 --- a/test/fixtures/config/flags/gulpfile/is/here/gulpfile-by-prj-cfg.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log('This gulpfile : ' + __filename); - console.log('The current directory : ' + process.cwd()); - done(); -}); diff --git a/test/fixtures/config/flags/gulpfile/is/here/gulpfile.js b/test/fixtures/config/flags/gulpfile/is/here/gulpfile.js deleted file mode 100644 index 61b4199a..00000000 --- a/test/fixtures/config/flags/gulpfile/is/here/gulpfile.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log('This gulpfile : ' + __filename); - console.log('The current directory : ' + process.cwd()); - done(); -}); diff --git a/test/fixtures/config/flags/gulpfile/override-by-cliflag/.gulp.js b/test/fixtures/config/flags/gulpfile/override-by-cliflag/.gulp.js deleted file mode 100644 index 3aa3b2db..00000000 --- a/test/fixtures/config/flags/gulpfile/override-by-cliflag/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - gulpfile: "../cwd/gulpfile.js" -}; diff --git a/test/fixtures/config/flags/gulpfile/override-by-cliflag/mygulpfile.js b/test/fixtures/config/flags/gulpfile/override-by-cliflag/mygulpfile.js deleted file mode 100644 index 9dc9c041..00000000 --- a/test/fixtures/config/flags/gulpfile/override-by-cliflag/mygulpfile.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log('Gulpfile : ' + __filename); - done(); -}); diff --git a/test/fixtures/config/flags/gulpfile/prj/.gulp.js b/test/fixtures/config/flags/gulpfile/prj/.gulp.js deleted file mode 100644 index 321e3bdf..00000000 --- a/test/fixtures/config/flags/gulpfile/prj/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - gulpfile: "../is/here/gulpfile-by-prj-cfg.js" -}; diff --git a/test/fixtures/config/flags/gulpfile/prj/findup/.gitkeep b/test/fixtures/config/flags/gulpfile/prj/findup/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/config/flags/gulpfile/use-current-cfg/current-dir/.gulp.js b/test/fixtures/config/flags/gulpfile/use-current-cfg/current-dir/.gulp.js deleted file mode 100644 index 8e905bea..00000000 --- a/test/fixtures/config/flags/gulpfile/use-current-cfg/current-dir/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - gulpfile: './gulpfile-2.js', -}; diff --git a/test/fixtures/config/flags/gulpfile/use-current-cfg/current-dir/gulpfile-2.js b/test/fixtures/config/flags/gulpfile/use-current-cfg/current-dir/gulpfile-2.js deleted file mode 100644 index a2e5369a..00000000 --- a/test/fixtures/config/flags/gulpfile/use-current-cfg/current-dir/gulpfile-2.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(__filename); - done(); -}); diff --git a/test/fixtures/config/flags/gulpfile/use-current-cfg/gulpfile.js b/test/fixtures/config/flags/gulpfile/use-current-cfg/gulpfile.js deleted file mode 100644 index a2e5369a..00000000 --- a/test/fixtures/config/flags/gulpfile/use-current-cfg/gulpfile.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(__filename); - done(); -}); diff --git a/test/fixtures/config/flags/logLevel/L/.gulp.js b/test/fixtures/config/flags/logLevel/L/.gulp.js deleted file mode 100644 index fca4e6b7..00000000 --- a/test/fixtures/config/flags/logLevel/L/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - logLevel: 1 - } -} diff --git a/test/fixtures/config/flags/logLevel/L/gulpfile.js b/test/fixtures/config/flags/logLevel/L/gulpfile.js deleted file mode 100644 index 42466b03..00000000 --- a/test/fixtures/config/flags/logLevel/L/gulpfile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - done(); -}); diff --git a/test/fixtures/config/flags/logLevel/LL/.gulp.js b/test/fixtures/config/flags/logLevel/LL/.gulp.js deleted file mode 100644 index 033e74d7..00000000 --- a/test/fixtures/config/flags/logLevel/LL/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - logLevel: 2 - } -}; diff --git a/test/fixtures/config/flags/logLevel/LL/gulpfile.js b/test/fixtures/config/flags/logLevel/LL/gulpfile.js deleted file mode 100644 index 42466b03..00000000 --- a/test/fixtures/config/flags/logLevel/LL/gulpfile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - done(); -}); diff --git a/test/fixtures/config/flags/logLevel/LLL/.gulp.js b/test/fixtures/config/flags/logLevel/LLL/.gulp.js deleted file mode 100644 index 5120f6f1..00000000 --- a/test/fixtures/config/flags/logLevel/LLL/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - logLevel: 3 - } -}; diff --git a/test/fixtures/config/flags/logLevel/LLL/gulpfile.js b/test/fixtures/config/flags/logLevel/LLL/gulpfile.js deleted file mode 100644 index 42466b03..00000000 --- a/test/fixtures/config/flags/logLevel/LLL/gulpfile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - done(); -}); diff --git a/test/fixtures/config/flags/logLevel/gulpfile.js b/test/fixtures/config/flags/logLevel/gulpfile.js deleted file mode 100644 index 42466b03..00000000 --- a/test/fixtures/config/flags/logLevel/gulpfile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - done(); -}); diff --git a/test/fixtures/config/flags/nodeFlags/array/.gulp.js b/test/fixtures/config/flags/nodeFlags/array/.gulp.js deleted file mode 100644 index 29053b1a..00000000 --- a/test/fixtures/config/flags/nodeFlags/array/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - nodeFlags: ["--lazy", "--trace-deprecation"] -} diff --git a/test/fixtures/config/flags/nodeFlags/array/gulpfile.js b/test/fixtures/config/flags/nodeFlags/array/gulpfile.js deleted file mode 100644 index b1e4e02a..00000000 --- a/test/fixtures/config/flags/nodeFlags/array/gulpfile.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -exports.default = function(done) { - console.log('Default'); - done(); -}; diff --git a/test/fixtures/config/flags/nodeFlags/null/.gulp.js b/test/fixtures/config/flags/nodeFlags/null/.gulp.js deleted file mode 100644 index 4f613ce0..00000000 --- a/test/fixtures/config/flags/nodeFlags/null/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - nodeFlags: null, -}; diff --git a/test/fixtures/config/flags/nodeFlags/null/gulpfile.js b/test/fixtures/config/flags/nodeFlags/null/gulpfile.js deleted file mode 100644 index b1e4e02a..00000000 --- a/test/fixtures/config/flags/nodeFlags/null/gulpfile.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -exports.default = function(done) { - console.log('Default'); - done(); -}; diff --git a/test/fixtures/config/flags/nodeFlags/string/.gulp.js b/test/fixtures/config/flags/nodeFlags/string/.gulp.js deleted file mode 100644 index f14523e4..00000000 --- a/test/fixtures/config/flags/nodeFlags/string/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - nodeFlags: '--lazy', -}; diff --git a/test/fixtures/config/flags/nodeFlags/string/gulpfile.js b/test/fixtures/config/flags/nodeFlags/string/gulpfile.js deleted file mode 100644 index b1e4e02a..00000000 --- a/test/fixtures/config/flags/nodeFlags/string/gulpfile.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -exports.default = function(done) { - console.log('Default'); - done(); -}; diff --git a/test/fixtures/config/flags/nodeFlags/undefined/.gulp.js b/test/fixtures/config/flags/nodeFlags/undefined/.gulp.js deleted file mode 100644 index 78532965..00000000 --- a/test/fixtures/config/flags/nodeFlags/undefined/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - nodeFlags: undefined, -}; diff --git a/test/fixtures/config/flags/nodeFlags/undefined/gulpfile.js b/test/fixtures/config/flags/nodeFlags/undefined/gulpfile.js deleted file mode 100644 index b1e4e02a..00000000 --- a/test/fixtures/config/flags/nodeFlags/undefined/gulpfile.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -exports.default = function(done) { - console.log('Default'); - done(); -}; diff --git a/test/fixtures/config/flags/preload/array/.gulp.js b/test/fixtures/config/flags/preload/array/.gulp.js deleted file mode 100644 index da5c398f..00000000 --- a/test/fixtures/config/flags/preload/array/.gulp.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - preload: [ - "./preload_one", - "./preload_two" - ] -}; diff --git a/test/fixtures/config/flags/preload/array/gulpfile.js b/test/fixtures/config/flags/preload/array/gulpfile.js deleted file mode 100644 index 496e068c..00000000 --- a/test/fixtures/config/flags/preload/array/gulpfile.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(global.preload_one); - console.log(global.preload_two); - done(); -}); diff --git a/test/fixtures/config/flags/preload/array/preload_one.js b/test/fixtures/config/flags/preload/array/preload_one.js deleted file mode 100644 index f9a04a11..00000000 --- a/test/fixtures/config/flags/preload/array/preload_one.js +++ /dev/null @@ -1 +0,0 @@ -global.preload_one = 'preload one!'; diff --git a/test/fixtures/config/flags/preload/array/preload_two.js b/test/fixtures/config/flags/preload/array/preload_two.js deleted file mode 100644 index e9014b3e..00000000 --- a/test/fixtures/config/flags/preload/array/preload_two.js +++ /dev/null @@ -1 +0,0 @@ -global.preload_two = 'preload two!'; diff --git a/test/fixtures/config/flags/preload/join-flags/.gulp.js b/test/fixtures/config/flags/preload/join-flags/.gulp.js deleted file mode 100644 index fe2a9b08..00000000 --- a/test/fixtures/config/flags/preload/join-flags/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - preload: [ - "./preload_two" - ] -}; diff --git a/test/fixtures/config/flags/preload/join-flags/gulpfile.js b/test/fixtures/config/flags/preload/join-flags/gulpfile.js deleted file mode 100644 index 496e068c..00000000 --- a/test/fixtures/config/flags/preload/join-flags/gulpfile.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(global.preload_one); - console.log(global.preload_two); - done(); -}); diff --git a/test/fixtures/config/flags/preload/join-flags/preload_one.js b/test/fixtures/config/flags/preload/join-flags/preload_one.js deleted file mode 100644 index f9a04a11..00000000 --- a/test/fixtures/config/flags/preload/join-flags/preload_one.js +++ /dev/null @@ -1 +0,0 @@ -global.preload_one = 'preload one!'; diff --git a/test/fixtures/config/flags/preload/join-flags/preload_two.js b/test/fixtures/config/flags/preload/join-flags/preload_two.js deleted file mode 100644 index e9014b3e..00000000 --- a/test/fixtures/config/flags/preload/join-flags/preload_two.js +++ /dev/null @@ -1 +0,0 @@ -global.preload_two = 'preload two!'; diff --git a/test/fixtures/config/flags/preload/preload.js b/test/fixtures/config/flags/preload/preload.js deleted file mode 100644 index 3b5d0c74..00000000 --- a/test/fixtures/config/flags/preload/preload.js +++ /dev/null @@ -1 +0,0 @@ -global.preload = 'hello preload!'; diff --git a/test/fixtures/config/flags/preload/string/.gulp.js b/test/fixtures/config/flags/preload/string/.gulp.js deleted file mode 100644 index cb913254..00000000 --- a/test/fixtures/config/flags/preload/string/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - preload: "./preload" -}; diff --git a/test/fixtures/config/flags/preload/string/gulpfile.js b/test/fixtures/config/flags/preload/string/gulpfile.js deleted file mode 100644 index 91fc5801..00000000 --- a/test/fixtures/config/flags/preload/string/gulpfile.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(global.preload); - done(); -}); diff --git a/test/fixtures/config/flags/preload/string/preload.js b/test/fixtures/config/flags/preload/string/preload.js deleted file mode 100644 index 3b5d0c74..00000000 --- a/test/fixtures/config/flags/preload/string/preload.js +++ /dev/null @@ -1 +0,0 @@ -global.preload = 'hello preload!'; diff --git a/test/fixtures/config/flags/preload/with-absolute/.gulp.js b/test/fixtures/config/flags/preload/with-absolute/.gulp.js deleted file mode 100644 index 1e7872b2..00000000 --- a/test/fixtures/config/flags/preload/with-absolute/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -var path = require('path'); - -module.exports = { - preload: path.join(__dirname, '../preload'), -}; diff --git a/test/fixtures/config/flags/preload/with-absolute/gulpfile.js b/test/fixtures/config/flags/preload/with-absolute/gulpfile.js deleted file mode 100644 index 91fc5801..00000000 --- a/test/fixtures/config/flags/preload/with-absolute/gulpfile.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(global.preload); - done(); -}); diff --git a/test/fixtures/config/flags/preload/with-cwd/.gulp.js b/test/fixtures/config/flags/preload/with-cwd/.gulp.js deleted file mode 100644 index e51966f4..00000000 --- a/test/fixtures/config/flags/preload/with-cwd/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - preload: "../preload" -}; diff --git a/test/fixtures/config/flags/preload/with-cwd/gulpfile.js b/test/fixtures/config/flags/preload/with-cwd/gulpfile.js deleted file mode 100644 index 91fc5801..00000000 --- a/test/fixtures/config/flags/preload/with-cwd/gulpfile.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - console.log(global.preload); - done(); -}); diff --git a/test/fixtures/config/flags/series/f/.gulp.js b/test/fixtures/config/flags/series/f/.gulp.js deleted file mode 100644 index 6605aca5..00000000 --- a/test/fixtures/config/flags/series/f/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - series: false - } -}; diff --git a/test/fixtures/config/flags/series/f/gulpfile.js b/test/fixtures/config/flags/series/f/gulpfile.js deleted file mode 100644 index 803710da..00000000 --- a/test/fixtures/config/flags/series/f/gulpfile.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function noop(cb) { - cb(); -} - -function delayed(cb) { - setTimeout(cb, 100); -} - -gulp.task('task1', delayed); -gulp.task('task2', noop); diff --git a/test/fixtures/config/flags/series/t/.gulp.js b/test/fixtures/config/flags/series/t/.gulp.js deleted file mode 100644 index f21fe066..00000000 --- a/test/fixtures/config/flags/series/t/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - series: true - } -}; diff --git a/test/fixtures/config/flags/series/t/gulpfile.js b/test/fixtures/config/flags/series/t/gulpfile.js deleted file mode 100644 index 803710da..00000000 --- a/test/fixtures/config/flags/series/t/gulpfile.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function noop(cb) { - cb(); -} - -function delayed(cb) { - setTimeout(cb, 100); -} - -gulp.task('task1', delayed); -gulp.task('task2', noop); diff --git a/test/fixtures/config/flags/silent/f/.gulp.js b/test/fixtures/config/flags/silent/f/.gulp.js deleted file mode 100644 index 4630a77a..00000000 --- a/test/fixtures/config/flags/silent/f/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - silent: false - } -}; diff --git a/test/fixtures/config/flags/silent/f/gulpfile.js b/test/fixtures/config/flags/silent/f/gulpfile.js deleted file mode 100644 index 42466b03..00000000 --- a/test/fixtures/config/flags/silent/f/gulpfile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - done(); -}); diff --git a/test/fixtures/config/flags/silent/t/.gulp.js b/test/fixtures/config/flags/silent/t/.gulp.js deleted file mode 100644 index 22486fd8..00000000 --- a/test/fixtures/config/flags/silent/t/.gulp.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - flags: { - silent: true - } -}; diff --git a/test/fixtures/config/flags/silent/t/gulpfile.js b/test/fixtures/config/flags/silent/t/gulpfile.js deleted file mode 100644 index 42466b03..00000000 --- a/test/fixtures/config/flags/silent/t/gulpfile.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -gulp.task('default', function(done) { - done(); -}); diff --git a/test/fixtures/config/flags/sortTasks/f/.gulp.js b/test/fixtures/config/flags/sortTasks/f/.gulp.js deleted file mode 100644 index e4640d82..00000000 --- a/test/fixtures/config/flags/sortTasks/f/.gulp.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - gulpfile: "../../../../gulpfiles/gulpfile-4.js", - flags: { - sortTasks: false - } -}; diff --git a/test/fixtures/config/flags/sortTasks/t/.gulp.js b/test/fixtures/config/flags/sortTasks/t/.gulp.js deleted file mode 100644 index aae6877b..00000000 --- a/test/fixtures/config/flags/sortTasks/t/.gulp.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - gulpfile: "../../../../gulpfiles/gulpfile-4.js", - flags: { - sortTasks: true - } -}; diff --git a/test/fixtures/config/flags/tasksDepth/.gulp.js b/test/fixtures/config/flags/tasksDepth/.gulp.js deleted file mode 100644 index 6960b163..00000000 --- a/test/fixtures/config/flags/tasksDepth/.gulp.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - gulpfile: "../../../gulpfiles/gulpfile-4.js", - flags: { - tasksDepth: 4 - } -}; diff --git a/test/fixtures/config/foo/bar/.gulp.js b/test/fixtures/config/foo/bar/.gulp.js deleted file mode 100644 index 4c3e35e7..00000000 --- a/test/fixtures/config/foo/bar/.gulp.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - description: "Description by .gulp.json in directory foo/bar" -}; diff --git a/test/fixtures/config/foo/bar/.gulp.json b/test/fixtures/config/foo/bar/.gulp.json new file mode 100644 index 00000000..186db419 --- /dev/null +++ b/test/fixtures/config/foo/bar/.gulp.json @@ -0,0 +1,3 @@ +{ + "description": "Description by .gulp.json in directory foo/bar" +} diff --git a/test/fixtures/config/foo/bar/baz/.gitkeep b/test/fixtures/config/foo/bar/baz/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/config/foo/bar/quux/.gulp.babel.js b/test/fixtures/config/foo/bar/baz/.gulp.babel.js similarity index 66% rename from test/fixtures/config/foo/bar/quux/.gulp.babel.js rename to test/fixtures/config/foo/bar/baz/.gulp.babel.js index 92986942..4e6e98c4 100644 --- a/test/fixtures/config/foo/bar/quux/.gulp.babel.js +++ b/test/fixtures/config/foo/bar/baz/.gulp.babel.js @@ -1 +1,3 @@ -exports.description = 'DESCRIPTION BY .gulp.babel.js in directory foo/bar/quux' +// jscs:disable + +exports.description = 'DESCRIPTION BY .gulp.babel.js in directory foo/bar/baz' diff --git a/test/fixtures/config/theming/ARGV_ERROR/.gulp.js b/test/fixtures/config/theming/ARGV_ERROR/.gulp.js deleted file mode 100644 index 674530d6..00000000 --- a/test/fixtures/config/theming/ARGV_ERROR/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.ARGV_ERROR) { - return '**' + data.message + '**'; - } - } -}; diff --git a/test/fixtures/config/theming/ARGV_ERROR/gulpfile.js b/test/fixtures/config/theming/ARGV_ERROR/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/ARGV_ERROR/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/COMPLETION_TYPE_MISSING/.gulp.js b/test/fixtures/config/theming/COMPLETION_TYPE_MISSING/.gulp.js deleted file mode 100644 index 0d1b6b4d..00000000 --- a/test/fixtures/config/theming/COMPLETION_TYPE_MISSING/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.COMPLETION_TYPE_MISSING) { - return 'NO COMPLETION TYPE'; - } - } -}; diff --git a/test/fixtures/config/theming/COMPLETION_TYPE_MISSING/gulpfile.js b/test/fixtures/config/theming/COMPLETION_TYPE_MISSING/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/COMPLETION_TYPE_MISSING/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/COMPLETION_TYPE_UNKNOWN/.gulp.js b/test/fixtures/config/theming/COMPLETION_TYPE_UNKNOWN/.gulp.js deleted file mode 100644 index 5db07839..00000000 --- a/test/fixtures/config/theming/COMPLETION_TYPE_UNKNOWN/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.COMPLETION_TYPE_UNKNOWN) { - return 'GULP COMPLETION TYPE **' + data.name + '** IS NOT FOUND'; - } - } -}; diff --git a/test/fixtures/config/theming/COMPLETION_TYPE_UNKNOWN/gulpfile.js b/test/fixtures/config/theming/COMPLETION_TYPE_UNKNOWN/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/COMPLETION_TYPE_UNKNOWN/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/CWD_CHANGED/.gulp.js b/test/fixtures/config/theming/CWD_CHANGED/.gulp.js deleted file mode 100644 index abdb16ba..00000000 --- a/test/fixtures/config/theming/CWD_CHANGED/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.CWD_CHANGED) { - return 'CHANGE CWD TO **' + data.cwd + '**'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/CWD_CHANGED/gulpfile.js b/test/fixtures/config/theming/CWD_CHANGED/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/CWD_CHANGED/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/DESCRIPTION/.gulp.js b/test/fixtures/config/theming/DESCRIPTION/.gulp.js deleted file mode 100644 index 6bfacc09..00000000 --- a/test/fixtures/config/theming/DESCRIPTION/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.DESCRIPTION) { - return '**DESCRIPTION**'; - } - } -}; diff --git a/test/fixtures/config/theming/DESCRIPTION/gulpfile.js b/test/fixtures/config/theming/DESCRIPTION/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/DESCRIPTION/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/DESCRIPTION/remove/.gulp.js b/test/fixtures/config/theming/DESCRIPTION/remove/.gulp.js deleted file mode 100644 index 8031c96d..00000000 --- a/test/fixtures/config/theming/DESCRIPTION/remove/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.DESCRIPTION) { - return false; - } - } -}; diff --git a/test/fixtures/config/theming/DESCRIPTION/remove/gulpfile.js b/test/fixtures/config/theming/DESCRIPTION/remove/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/DESCRIPTION/remove/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/EXEC_ERROR/.gulp.js b/test/fixtures/config/theming/EXEC_ERROR/.gulp.js deleted file mode 100644 index 853d150c..00000000 --- a/test/fixtures/config/theming/EXEC_ERROR/.gulp.js +++ /dev/null @@ -1,13 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.EXEC_ERROR) { - return 'FAIL TO RUN'; - } - - if (data.tag === messages.GULPFILE) { - throw new Error('Crash before task execution'); - } - } -}; diff --git a/test/fixtures/config/theming/EXEC_ERROR/gulpfile.js b/test/fixtures/config/theming/EXEC_ERROR/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/EXEC_ERROR/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/GULPFILE/.gulp.js b/test/fixtures/config/theming/GULPFILE/.gulp.js deleted file mode 100644 index cbc5684f..00000000 --- a/test/fixtures/config/theming/GULPFILE/.gulp.js +++ /dev/null @@ -1,13 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.GULPFILE) { - return 'USING GULPFILE **abcxyz**'; - } - - // Silence all other messages for test - return false; - } -}; - diff --git a/test/fixtures/config/theming/GULPFILE/gulpfile.js b/test/fixtures/config/theming/GULPFILE/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/GULPFILE/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/GULPLOG_DEPRECATED/.gulp.js b/test/fixtures/config/theming/GULPLOG_DEPRECATED/.gulp.js deleted file mode 100644 index 413c704b..00000000 --- a/test/fixtures/config/theming/GULPLOG_DEPRECATED/.gulp.js +++ /dev/null @@ -1,14 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.GULPLOG_DEPRECATED) { - return 'GULPLOG V1 IS DEPRECATED'; - } - - return false; - }, - timestamp: function () { - return false; - } -}; diff --git a/test/fixtures/config/theming/GULPLOG_DEPRECATED/gulpfile.js b/test/fixtures/config/theming/GULPLOG_DEPRECATED/gulpfile.js deleted file mode 100644 index aa34f0c8..00000000 --- a/test/fixtures/config/theming/GULPLOG_DEPRECATED/gulpfile.js +++ /dev/null @@ -1,6 +0,0 @@ -var gulplog = require('@gulpjs/gulplog-v1'); - -exports.default = function(done) { - gulplog.error('Some error here'); - done(); -} diff --git a/test/fixtures/config/theming/LOADER_FAILURE/.gulp.js b/test/fixtures/config/theming/LOADER_FAILURE/.gulp.js deleted file mode 100644 index 6ae4c154..00000000 --- a/test/fixtures/config/theming/LOADER_FAILURE/.gulp.js +++ /dev/null @@ -1,14 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.LOADER_FAILURE) { - return 'FAIL TO LOAD **' + data.name + '**'; - } - - if (data.tag === messages.LOADER_ERROR) { - // Silence for test - return false; - } - } -}; diff --git a/test/fixtures/config/theming/LOADER_FAILURE/gulpfile.coffee b/test/fixtures/config/theming/LOADER_FAILURE/gulpfile.coffee deleted file mode 100644 index 1f8b8541..00000000 --- a/test/fixtures/config/theming/LOADER_FAILURE/gulpfile.coffee +++ /dev/null @@ -1 +0,0 @@ -console.log 'hello' diff --git a/test/fixtures/config/theming/LOADER_SUCCESS/.gulp.js b/test/fixtures/config/theming/LOADER_SUCCESS/.gulp.js deleted file mode 100644 index 2079b8ac..00000000 --- a/test/fixtures/config/theming/LOADER_SUCCESS/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.LOADER_SUCCESS) { - return 'LOADED **' + data.name + '**!'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/LOADER_SUCCESS/gulpfile.babel.js b/test/fixtures/config/theming/LOADER_SUCCESS/gulpfile.babel.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/LOADER_SUCCESS/gulpfile.babel.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/MISSING_GULP/.gulp.js b/test/fixtures/config/theming/MISSING_GULP/.gulp.js deleted file mode 100644 index a01c5ca4..00000000 --- a/test/fixtures/config/theming/MISSING_GULP/.gulp.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - message: function (data) { - // Using `Symbol.for()` to avoid node_modules - if (data.tag === Symbol.for('GULP_CLI_MISSING_GULP')) { - return 'GULP NOT FOUND IN **' + data.cwd + '**'; - } - - if (data.tag === Symbol.for('GULP_CLI_NPM_INSTALL_GULP')) { - // Silence for test - return false; - } - }, - timestamp: function () { - return false; - } -}; diff --git a/test/fixtures/config/theming/MISSING_GULPFILE/.gulp.js b/test/fixtures/config/theming/MISSING_GULPFILE/.gulp.js deleted file mode 100644 index f5c441a7..00000000 --- a/test/fixtures/config/theming/MISSING_GULPFILE/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.MISSING_GULPFILE) { - return 'NO GULPFILE'; - } - } -}; diff --git a/test/fixtures/config/theming/MISSING_NODE_MODULES/.gulp.js b/test/fixtures/config/theming/MISSING_NODE_MODULES/.gulp.js deleted file mode 100644 index 80cca25d..00000000 --- a/test/fixtures/config/theming/MISSING_NODE_MODULES/.gulp.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - message: function (data) { - // Using `Symbol.for()` to avoid node_modules - if (data.tag === Symbol.for('GULP_CLI_MISSING_NODE_MODULES')) { - return 'LOCAL MODULE NOT FOUND **' + data.cwd + '**'; - } - - if (data.tag === Symbol.for('GULP_CLI_NPM_INSTALL')) { - // Silence for test - return false; - } - } -}; - diff --git a/test/fixtures/config/theming/MISSING_NODE_MODULES/package.json b/test/fixtures/config/theming/MISSING_NODE_MODULES/package.json deleted file mode 100644 index 71897b01..00000000 --- a/test/fixtures/config/theming/MISSING_NODE_MODULES/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "node-modules-not-found", - "private": true, - "version": "1.0.0", - "description": "", - "main": ".gulp.js" -} diff --git a/test/fixtures/config/theming/NODE_FLAGS/.gulp.js b/test/fixtures/config/theming/NODE_FLAGS/.gulp.js deleted file mode 100644 index 33127d58..00000000 --- a/test/fixtures/config/theming/NODE_FLAGS/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.NODE_FLAGS) { - return 'RESPAWNED BY **' + data.flags + '**!'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/NODE_FLAGS/gulpfile.js b/test/fixtures/config/theming/NODE_FLAGS/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/NODE_FLAGS/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/PRELOAD_BEFORE/.gulp.js b/test/fixtures/config/theming/PRELOAD_BEFORE/.gulp.js deleted file mode 100644 index a9ccf495..00000000 --- a/test/fixtures/config/theming/PRELOAD_BEFORE/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.PRELOAD_BEFORE) { - return 'PRELOADING **' + data.name + '**!'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/PRELOAD_BEFORE/gulpfile.js b/test/fixtures/config/theming/PRELOAD_BEFORE/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/PRELOAD_BEFORE/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/PRELOAD_BEFORE/preload.js b/test/fixtures/config/theming/PRELOAD_BEFORE/preload.js deleted file mode 100644 index 3b5d0c74..00000000 --- a/test/fixtures/config/theming/PRELOAD_BEFORE/preload.js +++ /dev/null @@ -1 +0,0 @@ -global.preload = 'hello preload!'; diff --git a/test/fixtures/config/theming/PRELOAD_FAILURE/.gulp.js b/test/fixtures/config/theming/PRELOAD_FAILURE/.gulp.js deleted file mode 100644 index fc2a1570..00000000 --- a/test/fixtures/config/theming/PRELOAD_FAILURE/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.PRELOAD_FAILURE) { - return 'FAILED TO PRELOAD **' + data.name + '**'; - } - - // Silence everything else for test - return false; - } -}; diff --git a/test/fixtures/config/theming/PRELOAD_FAILURE/gulpfile.js b/test/fixtures/config/theming/PRELOAD_FAILURE/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/PRELOAD_FAILURE/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/PRELOAD_SUCCESS/.gulp.js b/test/fixtures/config/theming/PRELOAD_SUCCESS/.gulp.js deleted file mode 100644 index 177818cc..00000000 --- a/test/fixtures/config/theming/PRELOAD_SUCCESS/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.PRELOAD_SUCCESS) { - return 'PRELOADED **' + data.name + '**!'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/PRELOAD_SUCCESS/gulpfile.js b/test/fixtures/config/theming/PRELOAD_SUCCESS/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/PRELOAD_SUCCESS/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/PRELOAD_SUCCESS/preload.js b/test/fixtures/config/theming/PRELOAD_SUCCESS/preload.js deleted file mode 100644 index 3b5d0c74..00000000 --- a/test/fixtures/config/theming/PRELOAD_SUCCESS/preload.js +++ /dev/null @@ -1 +0,0 @@ -global.preload = 'hello preload!'; diff --git a/test/fixtures/config/theming/RESPAWNED/.gulp.js b/test/fixtures/config/theming/RESPAWNED/.gulp.js deleted file mode 100644 index 1b79a3c7..00000000 --- a/test/fixtures/config/theming/RESPAWNED/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.RESPAWNED) { - return 'RESPAWN!'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/RESPAWNED/gulpfile.js b/test/fixtures/config/theming/RESPAWNED/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/RESPAWNED/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/TASK_ERROR/.gulp.js b/test/fixtures/config/theming/TASK_ERROR/.gulp.js deleted file mode 100644 index 77f9004a..00000000 --- a/test/fixtures/config/theming/TASK_ERROR/.gulp.js +++ /dev/null @@ -1,16 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.TASK_ERROR) { - return '**TASK ERROR**'; - } - - // Silence everything else for test - return false; - }, - timestamp: function () { - // Silence timestamps for test - return false; - } -}; diff --git a/test/fixtures/config/theming/TASK_ERROR/gulpfile.js b/test/fixtures/config/theming/TASK_ERROR/gulpfile.js deleted file mode 100644 index eeb90fd6..00000000 --- a/test/fixtures/config/theming/TASK_ERROR/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - throw new Error('FAIL!'); -} diff --git a/test/fixtures/config/theming/TASK_FAILURE/.gulp.js b/test/fixtures/config/theming/TASK_FAILURE/.gulp.js deleted file mode 100644 index af699b5e..00000000 --- a/test/fixtures/config/theming/TASK_FAILURE/.gulp.js +++ /dev/null @@ -1,16 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.TASK_FAILURE) { - return 'TASK FAILURE: **' + data.task + '**'; - } - - // Silence everything else for test - return false; - }, - timestamp: function () { - // Silence timestamps for test - return false; - } -}; diff --git a/test/fixtures/config/theming/TASK_FAILURE/gulpfile.js b/test/fixtures/config/theming/TASK_FAILURE/gulpfile.js deleted file mode 100644 index eeb90fd6..00000000 --- a/test/fixtures/config/theming/TASK_FAILURE/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - throw new Error('FAIL!'); -} diff --git a/test/fixtures/config/theming/TASK_MISSING/.gulp.js b/test/fixtures/config/theming/TASK_MISSING/.gulp.js deleted file mode 100644 index 153f09fa..00000000 --- a/test/fixtures/config/theming/TASK_MISSING/.gulp.js +++ /dev/null @@ -1,13 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.GULPFILE) { - return 'Using gulpfile!'; - } - - if (data.tag === messages.TASK_MISSING) { - return 'TASK IS NOT FOUND: **' + data.task + '** SIMILAR ##' + data.similar.join('') + '##'; - } - } -}; diff --git a/test/fixtures/config/theming/TASK_MISSING/gulpfile.js b/test/fixtures/config/theming/TASK_MISSING/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/TASK_MISSING/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/TASK_START/.gulp.js b/test/fixtures/config/theming/TASK_START/.gulp.js deleted file mode 100644 index 671c2c5c..00000000 --- a/test/fixtures/config/theming/TASK_START/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.TASK_START) { - return 'START **' + data.task + '**'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/TASK_START/gulpfile.js b/test/fixtures/config/theming/TASK_START/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/TASK_START/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/TASK_STOP/.gulp.js b/test/fixtures/config/theming/TASK_STOP/.gulp.js deleted file mode 100644 index 23eee49b..00000000 --- a/test/fixtures/config/theming/TASK_STOP/.gulp.js +++ /dev/null @@ -1,12 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.TASK_STOP) { - return 'STOP **' + data.task + '**'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/config/theming/TASK_STOP/gulpfile.js b/test/fixtures/config/theming/TASK_STOP/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/TASK_STOP/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/TASK_SYNC/.gulp.js b/test/fixtures/config/theming/TASK_SYNC/.gulp.js deleted file mode 100644 index a4911fe5..00000000 --- a/test/fixtures/config/theming/TASK_SYNC/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.TASK_SYNC) { - return 'TASK **' + data.tasks + '** DID NOT COMPLETE'; - } - } -}; diff --git a/test/fixtures/config/theming/TASK_SYNC/gulpfile.js b/test/fixtures/config/theming/TASK_SYNC/gulpfile.js deleted file mode 100644 index 1e950f9a..00000000 --- a/test/fixtures/config/theming/TASK_SYNC/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - //done(); -} diff --git a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/.gulp.js b/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/.gulp.js deleted file mode 100644 index 47159f8f..00000000 --- a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.UNSUPPORTED_GULP_VERSION) { - return 'BAD GULP VERSION **' + data.version + '**'; - } - } -}; diff --git a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/gulpfile.js b/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/gulpfile.js deleted file mode 100644 index db73dd16..00000000 --- a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/gulpfile.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.default = function(done) { - done(); -} diff --git a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/node_modules/gulp/index.js b/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/node_modules/gulp/index.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/node_modules/gulp/package.json b/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/node_modules/gulp/package.json deleted file mode 100644 index 3585a2f6..00000000 --- a/test/fixtures/config/theming/UNSUPPORTED_GULP_VERSION/node_modules/gulp/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "gulp", - "description": "Test Package for Testing!", - "version": "1.2.3" -} diff --git a/test/fixtures/config/theming/USAGE/.gulp.js b/test/fixtures/config/theming/USAGE/.gulp.js deleted file mode 100644 index 0c064d41..00000000 --- a/test/fixtures/config/theming/USAGE/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.USAGE) { - return 'GULP USAGE'; - } - } -}; diff --git a/test/fixtures/config/theming/flags/.gulp.js b/test/fixtures/config/theming/flags/.gulp.js deleted file mode 100644 index 72020819..00000000 --- a/test/fixtures/config/theming/flags/.gulp.js +++ /dev/null @@ -1,76 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.FLAG_HELP) { - return '**HELP**'; - } - - if (data.tag === messages.FLAG_VERSION) { - return '**VERSION**'; - } - - if (data.tag === messages.FLAG_PRELOAD) { - return '**PRELOAD**'; - } - - if (data.tag === messages.FLAG_GULPFILE) { - return '**GULPFILE**'; - } - - if (data.tag === messages.FLAG_CWD) { - return '**CWD**'; - } - - if (data.tag === messages.FLAG_TASKS) { - return '**TASKS**'; - } - - if (data.tag === messages.FLAG_TASKS_SIMPLE) { - return '**TASKS SIMPLE**'; - } - - if (data.tag === messages.FLAG_TASKS_JSON) { - return '**TASKS JSON**'; - } - - if (data.tag === messages.FLAG_TASKS_DEPTH) { - return '**TASKS DEPTH**'; - } - - if (data.tag === messages.FLAG_COMPACT_TASKS) { - return '**COMPACT TASKS**'; - } - - if (data.tag === messages.FLAG_SORT_TASKS) { - return '**SORT_TASKS**'; - } - - if (data.tag === messages.FLAG_COLOR) { - return '**COLOR**'; - } - - if (data.tag === messages.FLAG_NO_COLOR) { - return '**NO COLOR**'; - } - - if (data.tag === messages.FLAG_SILENT) { - return '**SILENT**'; - } - - if (data.tag === messages.FLAG_CONTINUE) { - return '**CONTINUE**'; - } - - if (data.tag === messages.FLAG_SERIES) { - return '**SERIES**'; - } - - if (data.tag === messages.FLAG_LOG_LEVEL) { - return '**LOG LEVEL**'; - } - - // Silence all other messages for test - return false; - } -}; diff --git a/test/fixtures/copy-tree.json b/test/fixtures/copy-tree.json deleted file mode 100644 index acfb240c..00000000 --- a/test/fixtures/copy-tree.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "label": "Label of Top node", - "nodes": [ - { - "label": "Label of node 1", - "branch": true, - "nodes": [] - }, - { - "label": "Label of node 2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1", - "branch": false, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.2", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3", - "nodes": [ - { - "label": "Label of node 3.1", - "branch": true, - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [ - { - "label": "Label of node 2.1.1.1", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.1.2", - "nodes": [] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - }, - { - "label": "Label of node 3.2", - "nodes": [ - { - "label": "Label of node 2.1.1", - "nodes": [] - }, - { - "label": "Label of node 2.1.2", - "nodes": [ - { - "label": "Label of node 2.1.2.1", - "nodes": [] - } - ] - }, - { - "label": "Label of node 2.1.3", - "nodes": [] - } - ] - } - ] - } - ] -} diff --git a/test/fixtures/errors/bad-gulp-version/gulpfile.js b/test/fixtures/errors/bad-gulp-version/gulpfile.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/errors/bad-gulp-version/node_modules/gulp/index.js b/test/fixtures/errors/bad-gulp-version/node_modules/gulp/index.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/errors/bad-gulp-version/node_modules/gulp/package.json b/test/fixtures/errors/bad-gulp-version/node_modules/gulp/package.json deleted file mode 100644 index dbe8ece4..00000000 --- a/test/fixtures/errors/bad-gulp-version/node_modules/gulp/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "gulp", - "description": "Test Package for Testing!", - "version": "1.2.3", - "tags": [ - ], - "files": [ - ], - "licenses": [ - { - "type": "MIT", - "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" - } - ] -} diff --git a/test/fixtures/errors/package.json b/test/fixtures/errors/package.json deleted file mode 100644 index dbe8ece4..00000000 --- a/test/fixtures/errors/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "gulp", - "description": "Test Package for Testing!", - "version": "1.2.3", - "tags": [ - ], - "files": [ - ], - "licenses": [ - { - "type": "MIT", - "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" - } - ] -} diff --git a/test/fixtures/errors/yarn/yarn.lock b/test/fixtures/errors/yarn/yarn.lock deleted file mode 100644 index e69de29b..00000000 diff --git a/test/fixtures/gulpfiles/.gulp.js b/test/fixtures/gulpfiles/.gulp.js deleted file mode 100644 index 33b2e061..00000000 --- a/test/fixtures/gulpfiles/.gulp.js +++ /dev/null @@ -1,9 +0,0 @@ -var messages = require('@gulpjs/messages'); - -module.exports = { - message: function (data) { - if (data.tag === messages.DESCRIPTION) { - return "gulp-cli/test/fixtures/gulpfiles"; - } - } -}; diff --git a/test/fixtures/gulpfiles/.gulp.json b/test/fixtures/gulpfiles/.gulp.json new file mode 100644 index 00000000..65158fad --- /dev/null +++ b/test/fixtures/gulpfiles/.gulp.json @@ -0,0 +1,3 @@ +{ + "description" : "gulp-cli/test/fixtures/gulpfiles" +} diff --git a/test/fixtures/gulpfiles/gulpfile-4.js b/test/fixtures/gulpfiles/gulpfile-4.js deleted file mode 100644 index 79ab3653..00000000 --- a/test/fixtures/gulpfiles/gulpfile-4.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function func1(done) { - done(); -} - -function func2(done) { - done(); -} - -function func3(done) { - done(); -} - -function func4(done) { - done(); -} - -gulp.task('taskC', gulp.series(func1, func2)); - -gulp.task('taskB', gulp.parallel(func3, 'taskC')); - -gulp.task('default', gulp.parallel('taskC', gulp.series('taskB', func4))); - diff --git a/test/fixtures/gulpfiles/gulpfile-babel.babel.js b/test/fixtures/gulpfiles/gulpfile-babel.babel.js deleted file mode 100644 index 24cbbd5b..00000000 --- a/test/fixtures/gulpfiles/gulpfile-babel.babel.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function noop(cb) { - cb(); -} - -function described(cb) { - cb(); -} - -function delayed(cb) { - setTimeout(cb, 100); -} - -function errorFunction() { - throw new Error('Error!'); -} -function anon(cb) { - cb(); -} - -function notCompleting1() { - // Callback is not called -} - -function notCompleting2() { - // Callback is not called -} - -described.description = 'description'; - -gulp.task('test1', gulp.series(noop)); -gulp.task('test2', gulp.series('test1', noop)); -gulp.task('test3', gulp.series(described)); -gulp.task('test4', gulp.series(errorFunction, anon)); -gulp.task('test5', delayed); -gulp.task('test6', noop); -gulp.task('test7', notCompleting1); -gulp.task('test8', notCompleting2); - -gulp.task('default', gulp.series('test1', 'test3', noop)); diff --git a/test/fixtures/gulpfiles/gulpfile-dedup-errorlog.js b/test/fixtures/gulpfiles/gulpfile-dedup-errorlog.js deleted file mode 100644 index a9066b64..00000000 --- a/test/fixtures/gulpfiles/gulpfile-dedup-errorlog.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; -var gulp = require('gulp'); -gulp.task('a', function() { - throw new Error('Task \'a\' failed!'); -}); -gulp.task('b', gulp.parallel('a')); -gulp.task('default', gulp.series(gulp.parallel('b'))); diff --git a/test/fixtures/gulpfiles/gulpfile-exports.babel.js b/test/fixtures/gulpfiles/gulpfile-exports.babel.js index f27b370c..1ebf6b62 100644 --- a/test/fixtures/gulpfiles/gulpfile-exports.babel.js +++ b/test/fixtures/gulpfiles/gulpfile-exports.babel.js @@ -8,15 +8,3 @@ export function clean(){}; export function build(){}; export const string = 'no function'; export const dist = gulp.series(clean, build); -function p1(){} -function p2(){} -export const p = gulp.parallel(p1, p2); - -export const sTest = gulp.series(clean, build); -sTest.displayName = 's-test'; - -export const pTest = gulp.parallel(p1, p2); -pTest.displayName = 'p-test'; - -export function fTest(){}; -fTest.displayName = 'f-test'; diff --git a/test/fixtures/gulpfiles/gulpfile-parallel-failure.js b/test/fixtures/gulpfiles/gulpfile-parallel-failure.js deleted file mode 100644 index c5c2079c..00000000 --- a/test/fixtures/gulpfiles/gulpfile-parallel-failure.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var gulp = require('gulp'); - -function noop(cb) { - cb(); -} - -function errorFunction(cb) { - cb(new Error('Error!')); -} - -function notCompleting1() { - // Callback is not called -} - -gulp.task('default', gulp.parallel(errorFunction, noop)); -gulp.task('broken', gulp.parallel(errorFunction, noop, notCompleting1)); diff --git a/test/fixtures/gulpfiles/gulpfile-tla.mjs b/test/fixtures/gulpfiles/gulpfile-tla.mjs deleted file mode 100644 index c6a97a4d..00000000 --- a/test/fixtures/gulpfiles/gulpfile-tla.mjs +++ /dev/null @@ -1,7 +0,0 @@ -const dynamicNoop = await Promise.resolve(function noop(cb) { - cb(); -}); - -export const registered = dynamicNoop; -export function exported(){}; -export const string = 'no function'; diff --git a/test/fixtures/gulpfiles/gulpfile.js b/test/fixtures/gulpfiles/gulpfile.js index 24cbbd5b..0a8b8112 100644 --- a/test/fixtures/gulpfiles/gulpfile.js +++ b/test/fixtures/gulpfiles/gulpfile.js @@ -3,41 +3,22 @@ var gulp = require('gulp'); function noop(cb) { - cb(); + return cb(); } - function described(cb) { cb(); } - -function delayed(cb) { - setTimeout(cb, 100); -} - function errorFunction() { throw new Error('Error!'); } function anon(cb) { - cb(); + return cb(); } - -function notCompleting1() { - // Callback is not called -} - -function notCompleting2() { - // Callback is not called -} - described.description = 'description'; gulp.task('test1', gulp.series(noop)); gulp.task('test2', gulp.series('test1', noop)); gulp.task('test3', gulp.series(described)); gulp.task('test4', gulp.series(errorFunction, anon)); -gulp.task('test5', delayed); -gulp.task('test6', noop); -gulp.task('test7', notCompleting1); -gulp.task('test8', notCompleting2); gulp.task('default', gulp.series('test1', 'test3', noop)); diff --git a/test/fixtures/gulpfiles/gulpfile.mjs b/test/fixtures/gulpfiles/gulpfile.mjs deleted file mode 100644 index 0b2b3885..00000000 --- a/test/fixtures/gulpfiles/gulpfile.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import gulp from 'gulp'; - -function noop(cb) { - cb(); -} - -gulp.task('registered', noop); - -export function exported(){}; -export const string = 'no function'; diff --git a/test/fixtures/gulpfiles/with-desc-and-flags.js b/test/fixtures/gulpfiles/with-desc-and-flags.js index 8a6937f4..b26eb4f1 100644 --- a/test/fixtures/gulpfiles/with-desc-and-flags.js +++ b/test/fixtures/gulpfiles/with-desc-and-flags.js @@ -7,7 +7,7 @@ clean.description = 'Delete dist folder'; gulp.task(clean); gulp.task('scripts', scripts); -function scripts() {} +function scripts() {}; scripts.description = 'Bundles JavaScript'; var styles = function() {}; @@ -17,20 +17,20 @@ gulp.task('styles').description = 'Compiles and bundles CSS'; var build = gulp.series('clean', 'scripts', 'styles'); build.description = 'Build all the things!'; build.flags = { - '--dev': '', + '--dev': 'un-minified', '--production': 'compressed into single bundle', '': 'dummy-empty-string', }; gulp.task('build', build); gulp.task('serve', serve); -function serve() {} +function serve() {}; serve.description = 'Serves files reloading'; serve.flags = { '--lr': 'with live reloading', }; -function watch() {} +function watch() {}; gulp.task('watch', watch); watch.description = 'Watch files and build on change'; diff --git a/test/fixtures/logging.js b/test/fixtures/logging.js index 7b28ae8a..e883884c 100644 --- a/test/fixtures/logging.js +++ b/test/fixtures/logging.js @@ -1,14 +1,12 @@ var log = require('gulplog'); var yargs = require('yargs'); -var toConsole = require('../../lib/shared/log/to-console'); -var cliOptions = require('../../lib/shared/options/cli-options'); -var buildTranslations = require('../../lib/shared/translate'); +var toConsole = require('../../lib/shared/log/toConsole'); +var cliOptions = require('../../lib/shared/cliOptions'); -var opts = yargs.options(cliOptions).parse(); +var parser = yargs.usage('', cliOptions); +var opts = parser.argv; -var translate = buildTranslations(); - -toConsole(log, opts, translate); +toConsole(log, opts); log.debug('test debug'); log.info('test info'); diff --git a/test/fixtures/verify/invalid-package.json b/test/fixtures/packages/invalid-package.json similarity index 94% rename from test/fixtures/verify/invalid-package.json rename to test/fixtures/packages/invalid-package.json index 4f99a0f2..29a15016 100644 --- a/test/fixtures/verify/invalid-package.json +++ b/test/fixtures/packages/invalid-package.json @@ -1,21 +1,21 @@ -{ - "name": "test-package", - "description": "Test Package for Testing!", - "version": "0.0.1", - "tags": [ - ], - "files": [ - ], - "dependencies": { - "gulp-blink": "^0.1.4" - }, - "engines": { - "node": ">= 0.9" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" - } - ] -} +{ + "name": "test-package", + "description": "Test Package for Testing!", + "version": "0.0.1", + "tags": [ + ], + "files": [ + ], + "dependencies": { + "gulp-blink": "^0.1.4" + }, + "engines": { + "node": ">= 0.9" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" + } + ] +} diff --git a/test/fixtures/verify/package.json b/test/fixtures/packages/package.json similarity index 94% rename from test/fixtures/verify/package.json rename to test/fixtures/packages/package.json index d5eeee96..73dbc76b 100644 --- a/test/fixtures/verify/package.json +++ b/test/fixtures/packages/package.json @@ -1,21 +1,21 @@ -{ - "name": "default-package", - "description": "Test Package for Testing!", - "version": "0.0.1", - "tags": [ - ], - "files": [ - ], - "dependencies": { - "gulp-blink": "^0.1.4" - }, - "engines": { - "node": ">= 0.9" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" - } - ] -} +{ + "name": "default-package", + "description": "Test Package for Testing!", + "version": "0.0.1", + "tags": [ + ], + "files": [ + ], + "dependencies": { + "gulp-blink": "^0.1.4" + }, + "engines": { + "node": ">= 0.9" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" + } + ] +} diff --git a/test/fixtures/verify/valid-package.json b/test/fixtures/packages/valid-package.json similarity index 94% rename from test/fixtures/verify/valid-package.json rename to test/fixtures/packages/valid-package.json index be2d488c..b9d30e04 100644 --- a/test/fixtures/verify/valid-package.json +++ b/test/fixtures/packages/valid-package.json @@ -1,21 +1,21 @@ -{ - "name": "test-package-2", - "description": "Test Package for Testing!", - "version": "0.0.1", - "tags": [ - ], - "files": [ - ], - "dependencies": { - "yargs": "^3.27.0" - }, - "engines": { - "node": ">= 0.9" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" - } - ] -} +{ + "name": "test-package-2", + "description": "Test Package for Testing!", + "version": "0.0.1", + "tags": [ + ], + "files": [ + ], + "dependencies": { + "yargs": "^3.27.0" + }, + "engines": { + "node": ">= 0.9" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE" + } + ] +} diff --git a/test/fixtures/test-error-module.js b/test/fixtures/test-error-module.js deleted file mode 100644 index ddf54a7b..00000000 --- a/test/fixtures/test-error-module.js +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint no-unreachable: off */ -throw new Error('from error module'); -console.log('inside error module'); diff --git a/test/fixtures/test-module-2.js b/test/fixtures/test-module-2.js deleted file mode 100644 index bab74223..00000000 --- a/test/fixtures/test-module-2.js +++ /dev/null @@ -1,4 +0,0 @@ -console.log('inside test module 2'); -exports = function() { - console.log('inside test module function 2'); -}; diff --git a/test/flags-continue.js b/test/flags-continue.js index cbf8a94f..b5013d1c 100644 --- a/test/flags-continue.js +++ b/test/flags-continue.js @@ -1,34 +1,33 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); +var runner = require('gulp-test-tools').gulpRunner; +var eraseTime = require('gulp-test-tools').eraseTime; +var eraseLapse = require('gulp-test-tools').eraseLapse; +var skipLines = require('gulp-test-tools').skipLines; +var headLines = require('gulp-test-tools').headLines; describe('flag: --continue', function() { it('continues execution when flag is set', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - 'test4', - '--continue', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); + runner({ verbose: false }) + .gulp('test4', '--continue', '--cwd ./test/fixtures/gulpfiles') + .run(cb); function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(sliceLines(stdout, 2)).toEqual( + expect(err).toNotEqual(null); + + stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); + expect(stdout).toEqual( 'Starting \'test4\'...\n' + 'Starting \'errorFunction\'...\n' + 'Starting \'anon\'...\n' + 'Finished \'anon\' after ?\n' + '' ); - expect(sliceLines(stderr, 0, 2)).toEqual( + + stderr = eraseLapse(eraseTime(headLines(stderr, 2))); + expect(stderr).toEqual( '\'errorFunction\' errored after ?\n' + 'Error: Error!' ); @@ -37,19 +36,23 @@ describe('flag: --continue', function() { }); it('stops execution when flag is not set', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('test4', '--cwd ./test/fixtures/gulpfiles'), opts, cb); + runner({ verbose: false }) + .gulp('test4', '--cwd ./test/fixtures/gulpfiles') + .run(cb); function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).not.toMatch('Starting \'anon\''); - stdout = sliceLines(stdout, 2); + expect(err).toNotEqual(null); + + expect(stdout).toNotMatch('Starting \'anon\''); + stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); expect(stdout).toEqual( 'Starting \'test4\'...\n' + 'Starting \'errorFunction\'...\n' + '' ); - expect(sliceLines(stderr, 0, 2)).toEqual( + + stderr = eraseLapse(eraseTime(headLines(stderr, 2))); + expect(stderr).toEqual( '\'errorFunction\' errored after ?\n' + 'Error: Error!' ); diff --git a/test/flags-gulpfile.js b/test/flags-gulpfile.js index 7c9316b7..f51b93e7 100644 --- a/test/flags-gulpfile.js +++ b/test/flags-gulpfile.js @@ -1,60 +1,29 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; +var runner = require('gulp-test-tools').gulpRunner; +var skipLines = require('gulp-test-tools').skipLines; +var headLines = require('gulp-test-tools').headLines; +var eraseTime = require('gulp-test-tools').eraseTime; +var eraseLapse = require('gulp-test-tools').eraseLapse; var path = require('path'); -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); - describe('flag: --gulpfile', function() { - it('Manually set path of gulpfile using --gulpfile', function(done) { + it('Manually set path of gulpfile', function(done) { var gulpfilePath = 'test/fixtures/gulpfiles/gulpfile-2.js'; - var opts = { cwd: baseDir }; - exec(gulp('--gulpfile', gulpfilePath), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - - var chgWorkdirLog = sliceLines(stdout, 0, 1); - var workdir = path.dirname(gulpfilePath).replace(/\//g, path.sep); - expect(chgWorkdirLog).toMatch('Working directory changed to '); - expect(chgWorkdirLog).toMatch(workdir); - - stdout = sliceLines(stdout, 2); - expect(stdout).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'logGulpfilePath\'...\n' + - path.resolve(gulpfilePath) + '\n' + - 'Finished \'logGulpfilePath\' after ?\n' + - 'Finished \'default\' after ?\n' + - '' - ); - done(err); - } - }); - - it('Manually set path of gulpfile using -f', function(done) { - var gulpfilePath = 'test/fixtures/gulpfiles/gulpfile-2.js'; - - var opts = { cwd: baseDir }; - exec(gulp('-f', gulpfilePath), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + runner({ verbose: false }) + .gulp('--gulpfile', gulpfilePath) + .run(cb); - var chgWorkdirLog = sliceLines(stdout, 0, 1); + function cb(err, stdout) { + var chgWorkdirLog = headLines(stdout, 1); var workdir = path.dirname(gulpfilePath).replace(/\//g, path.sep); expect(chgWorkdirLog).toMatch('Working directory changed to '); expect(chgWorkdirLog).toMatch(workdir); - stdout = sliceLines(stdout, 2); + stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); expect(stdout).toEqual( 'Starting \'default\'...\n' + 'Starting \'logGulpfilePath\'...\n' + diff --git a/test/flags-help.js b/test/flags-help.js index 3007e288..05f20f61 100644 --- a/test/flags-help.js +++ b/test/flags-help.js @@ -1,72 +1,43 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; +var runner = require('gulp-test-tools').gulpRunner; + var path = require('path'); var fs = require('fs'); -var gulp = require('./tool/gulp-cmd'); +// Erases a first space inserted by `chalk`. +function eraseFirstSpace(s) { + return s.replace(/^(\r\n|\n|\r)\s?/g, '\n'); +} -var baseDir = path.join(__dirname, '..'); var outputFile = path.join(__dirname, 'expected/flags-help.txt'); var outputText = fs.readFileSync(outputFile, 'utf8'); describe('flag: --help', function() { it('shows help using --help', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--help', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); + runner({ verbose: false }) + .gulp('--help', '--cwd ./test/fixtures/gulpfiles') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { + stdout = eraseFirstSpace(stdout); expect(stdout).toEqual(outputText); done(err); } }); it('shows help using short --h', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--h', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(outputText); - done(err); - } - }); - - it('avoids printing "Requiring external module *"', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--help', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-babel.babel.js' - ), opts, cb); + runner({ verbose: false }) + .gulp('--h', '--cwd ./test/fixtures/gulpfiles') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { + stdout = eraseFirstSpace(stdout); expect(stdout).toEqual(outputText); done(err); } }); - it('show error message and help if options are invalid', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('-f'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).not.toBeNull(); - expect(stdout).toEqual(''); - expect(stderr).toEqual('Not enough arguments following: f\n' + outputText); - done(); - } - }); }); diff --git a/test/flags-preload.js b/test/flags-preload.js deleted file mode 100644 index 8a666ddc..00000000 --- a/test/flags-preload.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var eraseTime = require('./tool/erase-time'); -var eraseLapse = require('./tool/erase-lapse'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); - -describe('flag: --preload', function() { - - it('preloads module before running gulpfile', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--preload ../test-module.js', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ../test-module.js'); - expect(sliceLines(stdout, 1, 2)).toEqual('inside test module'); - expect(sliceLines(stdout, 2, 3)).toEqual('Preloaded external module: ../test-module.js'); - - var chgWorkdirLog = sliceLines(stdout, 3, 4); - var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep); - expect(chgWorkdirLog).toMatch('Working directory changed to '); - expect(chgWorkdirLog).toMatch(workdir); - - stdout = sliceLines(stdout, 5); - expect(stdout).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'test1\'...\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'test1\' after ?\n' + - 'Starting \'test3\'...\n' + - 'Starting \'described\'...\n' + - 'Finished \'described\' after ?\n' + - 'Finished \'test3\' after ?\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'default\' after ?\n' + - '' - ); - done(err); - } - }); - - it('can preload multiple modules before running gulpfile', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--preload ../test-module.js', - '--preload ../test-module-2.js', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Preloading external module: ../test-module.js'); - expect(sliceLines(stdout, 1, 2)).toEqual('inside test module'); - expect(sliceLines(stdout, 2, 3)).toEqual('Preloaded external module: ../test-module.js'); - expect(sliceLines(stdout, 3, 4)).toEqual('Preloading external module: ../test-module-2.js'); - expect(sliceLines(stdout, 4, 5)).toEqual('inside test module 2'); - expect(sliceLines(stdout, 5, 6)).toEqual('Preloaded external module: ../test-module-2.js'); - done(err); - } - }); - - it('warns if module doesn\'t exist', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--preload ./null-module.js', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 2)).toEqual( - 'Preloading external module: ./null-module.js\n' + - 'Failed to preload external module: ./null-module.js' - ); - expect(sliceLines(stdout, 2, 3)).toMatch('Error: Cannot find module \'./null-module.js\''); - - var chgWorkdirLog = sliceLines(stdout, 3, 4); - var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep); - expect(chgWorkdirLog).toMatch('Working directory changed to '); - expect(chgWorkdirLog).toMatch(workdir); - - expect(sliceLines(stdout, 5)).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'test1\'...\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'test1\' after ?\n' + - 'Starting \'test3\'...\n' + - 'Starting \'described\'...\n' + - 'Finished \'described\' after ?\n' + - 'Finished \'test3\' after ?\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'default\' after ?\n' + - '' - ); - - done(err); - } - }); - - it('warns if module throw some error', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--preload ../test-error-module.js', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - stdout = eraseLapse(eraseTime(stdout)); - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 1, 2)).toEqual('Failed to preload external module: ../test-error-module.js'); - expect(sliceLines(stdout, 2, 3)).toMatch('Error: from error module'); - expect(stdout).not.toMatch('inside error module'); - - var chgWorkdirLog = sliceLines(stdout, 3, 4); - var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep); - expect(chgWorkdirLog).toMatch('Working directory changed to '); - expect(chgWorkdirLog).toMatch(workdir); - - expect(sliceLines(stdout, 5)).toEqual( - 'Starting \'default\'...\n' + - 'Starting \'test1\'...\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'test1\' after ?\n' + - 'Starting \'test3\'...\n' + - 'Starting \'described\'...\n' + - 'Finished \'described\' after ?\n' + - 'Finished \'test3\' after ?\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'default\' after ?\n' + - '' - ); - - done(err); - } - }); - -}); diff --git a/test/flags-require.js b/test/flags-require.js new file mode 100644 index 00000000..8af8ce88 --- /dev/null +++ b/test/flags-require.js @@ -0,0 +1,90 @@ +'use strict'; + +var expect = require('expect'); +var runner = require('gulp-test-tools').gulpRunner; +var skipLines = require('gulp-test-tools').skipLines; +var headLines = require('gulp-test-tools').headLines; +var eraseTime = require('gulp-test-tools').eraseTime; +var eraseLapse = require('gulp-test-tools').eraseLapse; +var path = require('path'); + +describe('flag: --require', function() { + + it('requires module before running gulpfile', function(done) { + runner({ verbose: false }) + .gulp('--require ../test-module.js', '--cwd ./test/fixtures/gulpfiles') + .run(cb); + + function cb(err, stdout) { + var insideLog = headLines(stdout, 1); + expect(insideLog).toEqual('inside test module'); + + var requireLog = eraseTime(headLines(stdout, 1, 1)); + expect(requireLog).toEqual( + 'Requiring external module ../test-module.js'); + + var chgWorkdirLog = headLines(stdout, 1, 2); + var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep); + expect(chgWorkdirLog).toMatch('Working directory changed to '); + expect(chgWorkdirLog).toMatch(workdir); + + stdout = eraseLapse(eraseTime(skipLines(stdout, 4))); + expect(stdout).toEqual( + 'Starting \'default\'...\n' + + 'Starting \'test1\'...\n' + + 'Starting \'noop\'...\n' + + 'Finished \'noop\' after ?\n' + + 'Finished \'test1\' after ?\n' + + 'Starting \'test3\'...\n' + + 'Starting \'described\'...\n' + + 'Finished \'described\' after ?\n' + + 'Finished \'test3\' after ?\n' + + 'Starting \'noop\'...\n' + + 'Finished \'noop\' after ?\n' + + 'Finished \'default\' after ?\n' + + '' + ); + done(err); + } + }); + + it('errors if module doesn\'t exist', function(done) { + runner({ verbose: false }) + .gulp('--require ./null-module.js', '--cwd ./test/fixtures/gulpfiles') + .run(cb); + + function cb(err, stdout, stderr) { + expect(stdout).toNotMatch('inside test module'); + expect(stdout).toNotMatch( + 'Requiring external module ../test-module.js'); + + var chgWorkdirLog = headLines(stdout, 1); + var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep); + expect(chgWorkdirLog).toMatch('Working directory changed to '); + expect(chgWorkdirLog).toMatch(workdir); + + stdout = eraseLapse(eraseTime(skipLines(stdout, 2))); + expect(stdout).toEqual( + 'Starting \'default\'...\n' + + 'Starting \'test1\'...\n' + + 'Starting \'noop\'...\n' + + 'Finished \'noop\' after ?\n' + + 'Finished \'test1\' after ?\n' + + 'Starting \'test3\'...\n' + + 'Starting \'described\'...\n' + + 'Finished \'described\' after ?\n' + + 'Finished \'test3\' after ?\n' + + 'Starting \'noop\'...\n' + + 'Finished \'noop\' after ?\n' + + 'Finished \'default\' after ?\n' + + '' + ); + + stderr = eraseTime(stderr); + expect(stderr).toEqual( + 'Failed to load external module ./null-module.js\n'); + done(err); + } + }); + +}); diff --git a/test/flags-series.js b/test/flags-series.js deleted file mode 100644 index b4ba6047..00000000 --- a/test/flags-series.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); - -describe('flag: --series', function() { - - it('runs tasks in series when flag is set', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - 'test5 test6', - '--series', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 2)).toEqual( - 'Starting \'test5\'...\n' + - 'Finished \'test5\' after ?\n' + - 'Starting \'test6\'...\n' + - 'Finished \'test6\' after ?\n' + - '' - ); - done(); - } - }); - - it('runs tasks in parallel when flag is not set', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - 'test5 test6', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).not.toMatch('Starting \'anon\''); - expect(sliceLines(stdout, 2)).toEqual( - 'Starting \'test5\'...\n' + - 'Starting \'test6\'...\n' + - 'Finished \'test6\' after ?\n' + - 'Finished \'test5\' after ?\n' + - '' - ); - done(); - } - }); - -}); diff --git a/test/flags-silent.js b/test/flags-silent.js index c7bc12b0..4e422a27 100644 --- a/test/flags-silent.js +++ b/test/flags-silent.js @@ -1,25 +1,16 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); +var runner = require('gulp-test-tools').gulpRunner; describe('flag: --silent', function() { it('prints nothing when silent flag is set', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--silent', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); + runner({ verbose: false }) + .gulp('--silent', '--cwd ./test/fixtures/gulpfiles') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { expect(stdout).toEqual(''); done(err); } diff --git a/test/flags-tasks-json.js b/test/flags-tasks-json.js index 5614ac33..3816b02b 100644 --- a/test/flags-tasks-json.js +++ b/test/flags-tasks-json.js @@ -1,93 +1,46 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; -var fs = require('fs'); +var fs = require('fs-extra'); var path = require('path'); -var rimraf = require('rimraf'); +var skipLines = require('gulp-test-tools').skipLines; +var runner = require('gulp-test-tools').gulpRunner; -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); var expected = require(path.join(__dirname, 'expected/flags-tasks-json.json')); describe('flag: --tasks-json', function() { it('prints the task list with no args', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks-json', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile.js' - ), opts, cb); + runner({ verbose: false }) + .gulp('--tasks-json --gulpfile ./test/fixtures/gulpfiles/gulpfile.js') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { + stdout = skipLines(stdout, 1); expect(JSON.parse(stdout)).toEqual(expected); - done(err); - } - }); - - it('prints the task list with the default description', function(done) { - var cwdPath = __dirname; - var gulpfilePath = path.join(__dirname, 'fixtures/gulpfiles/gulpfile.js'); - - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks-json', - '--cwd ', cwdPath, - '--gulpfile ', gulpfilePath - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var jsonObj = JSON.parse(stdout); - expect(jsonObj.label).toMatch('Tasks for '); - expect(jsonObj.nodes).toEqual(expected.nodes); - done(err); + done(); } }); it('writes the task list to file with path', function(done) { - var output = path.join(__dirname, '/output/'); - rimraf.sync(output); - fs.mkdirSync(output); - - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks-json ../../output/tasks.json', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile.js' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - stdout = stdout.split('\n').slice(1).join('\n'); - expect(stdout).toEqual(''); - var file = fs.readFileSync(path.join(output, '/tasks.json'), 'utf8'); - var parsedJson = JSON.parse(file); - expect(parsedJson).toEqual(expected); - rimraf.sync(output); - done(err); - } + fs.emptyDir(__dirname + '/output/', function(err) { + if (err) { + return done(err); + } + + runner({ verbose: false }) + .gulp('--tasks-json ../../output/tasks.json', + '--gulpfile ./test/fixtures/gulpfiles/gulpfile.js') + .run(cb); + + function cb(err) { + var file = fs.readFileSync(__dirname + '/output/tasks.json', 'utf8'); + var parsedJson = JSON.parse(file); + expect(parsedJson).toEqual(expected); + fs.removeSync(__dirname + '/output/'); + done(err); + } + }); }); - it('avoids printing "Requiring external module *"', function(done) { - // Disable the timeout for old node versions - this.timeout(0); - - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks-json', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-babel.babel.js' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(JSON.parse(stdout)).toEqual(expected); - done(err); - } - }); }); diff --git a/test/flags-tasks-simple.js b/test/flags-tasks-simple.js index a2f54c22..3cc796e1 100644 --- a/test/flags-tasks-simple.js +++ b/test/flags-tasks-simple.js @@ -1,46 +1,21 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; +var runner = require('gulp-test-tools').gulpRunner; var path = require('path'); var fs = require('fs'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); var outputFile = path.join(__dirname, 'expected/flags-tasks-simple.txt'); var outputText = fs.readFileSync(outputFile, 'utf8'); describe('flag: --tasks-simple', function() { it('prints the task list in simple format', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks-simple', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual(outputText); - done(err); - } - }); - - it('avoids printing "Requiring external module *"', function(done) { - // Disable the timeout for old node versions - this.timeout(0); - - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks-simple', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-babel.babel.js' - ), opts, cb); + runner({ verbose: false }) + .gulp('--tasks-simple', '--cwd ./test/fixtures/gulpfiles') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { expect(stdout).toEqual(outputText); done(err); } diff --git a/test/flags-tasks.js b/test/flags-tasks.js index 68bd2a6a..dc3959ba 100644 --- a/test/flags-tasks.js +++ b/test/flags-tasks.js @@ -1,178 +1,60 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; var fs = require('fs'); var path = require('path'); +var skipLines = require('gulp-test-tools').skipLines; +var eraseTime = require('gulp-test-tools').eraseTime; +var runner = require('gulp-test-tools').gulpRunner; -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, '..'); var expectedDir = path.join(__dirname, 'expected'); describe('flag: --tasks', function() { it('prints the task list', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--sort-tasks', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); + runner({ verbose: false }) + .gulp('--tasks --cwd ./test/fixtures/gulpfiles') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { var filepath = path.join(expectedDir, 'flags-tasks.txt'); var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(expected); - done(err); + stdout = eraseTime(skipLines(stdout, 1)); + expect(stdout).toEqual(expected); + done(); } }); - it('prints the task list with description and flags', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--sort-tasks', - '--gulpfile ./test/fixtures/gulpfiles/with-desc-and-flags.js', - '--cwd ./test/fixtures' - ), opts, cb); + it('print the task list with description and flags', function(done) { + runner({ verbose: false }) + .gulp('--tasks', + '--gulpfile ./test/fixtures/gulpfiles/with-desc-and-flags.js', + '--cwd ./test/fixtures') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { var filepath = path.join(expectedDir, 'with-desc-and-flags.txt'); var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(expected); - done(err); + stdout = eraseTime(skipLines(stdout, 1)); + expect(stdout).toEqual(expected); + done(); } }); - it('prints the task list by gulp.task(s).unwrap and gulp.task(s)', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--sort-tasks', - '--gulpfile ./test/fixtures/gulpfiles/by-unwrap-and-not-by-unwrap.js', - '--cwd ./test/fixtures' - ), opts, cb); + it('print the task list by gulp.task(s).unwrap and gulp.task(s)', + function(done) { + runner({ verbose: false }) + .gulp('--tasks', + '--gulpfile ./test/fixtures/gulpfiles/by-unwrap-and-not-by-unwrap.js', + '--cwd ./test/fixtures') + .run(cb); - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { var filepath = path.join(expectedDir, 'by-unwrap-and-not-by-unwrap.txt'); var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(expected); - done(err); - } - }); - - it('prints the task list without --sort-tasks flag', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-4.js' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'flags-tasks-unsorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(sliceLines(expected, 1)); - done(err); - } - }); - - it('prints the task list with --sort-tasks flag', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-4.js', - '--sort-tasks' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'flags-tasks-sorted.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(sliceLines(expected, 1)); - done(err); - } - }); - - it('prints the task list with --tasks-depth flag', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-4.js', - '--tasks-depth 4' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'flags-tasks-depth4.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(sliceLines(expected, 1)); - done(err); - } - }); - - it('prints the top task only if negative tasks depth is specified', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-4.js', - '--tasks-depth -1' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'flags-tasks-depth1.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(expected); - done(err); - } - }); - - it('prints the task list with --depth flag', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-4.js', - '--depth 4' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'flags-tasks-depth4.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(sliceLines(expected, 1)); - done(err); - } - }); - - it('prints the task list with --compact-tasks flag', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--tasks', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-4.js', - '--compact-tasks' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - var filepath = path.join(expectedDir, 'flags-tasks-compact.txt'); - var expected = fs.readFileSync(filepath, 'utf-8'); - expect(sliceLines(stdout, 1)).toEqual(sliceLines(expected, 1)); - done(err); + stdout = eraseTime(skipLines(stdout, 1)); + expect(stdout).toEqual(expected); + done(); } }); diff --git a/test/flags-v8flags.js b/test/flags-v8flags.js deleted file mode 100644 index 30dec323..00000000 --- a/test/flags-v8flags.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -var baseDir = path.join(__dirname, 'fixtures/gulpfiles'); - -describe('flags: v8flags', function() { - - it('Should respawn by a v8flag: --lazy', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--lazy'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Node flags detected: --lazy'); - expect(sliceLines(stdout, 1, 3)).toMatch('Respawned to PID: '); - done(err); - } - }); - - it('Should respawn by v8flags: --lazy --harmony', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--lazy --harmony'), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(sliceLines(stdout, 0, 1)).toEqual('Node flags detected: --harmony, --lazy'); - expect(sliceLines(stdout, 1, 3)).toMatch('Respawned to PID: '); - done(err); - } - }); -}); diff --git a/test/flags-verify.js b/test/flags-verify.js new file mode 100644 index 00000000..9a3a0af5 --- /dev/null +++ b/test/flags-verify.js @@ -0,0 +1,69 @@ +'use strict'; + +var expect = require('expect'); +var runner = require('gulp-test-tools').gulpRunner; +var eraseTime = require('gulp-test-tools').eraseTime; +var path = require('path'); + +describe('flag: --verify', function() { + + it('dependencies with invalid dependency', function(done) { + runner({ verbose: false }) + .gulp('--verify invalid-package.json', '--cwd ./test/fixtures/packages/') + .run(cb); + + function cb(err, stdout) { + expect(err).toNotEqual(null); + + stdout = eraseTime(stdout); + expect(stdout).toEqual( + 'Verifying plugins in ' + + path.resolve('./test/fixtures/packages/invalid-package.json') + + '\n' + + 'Blacklisted plugins found in this project:\n' + + 'gulp-blink: deprecated. use `blink` instead.\n' + + '' + ); + done(); + } + }); + + it('dependencies with valid dependency', function(done) { + runner({ verbose: false }) + .gulp('--verify valid-package.json', '--cwd ./test/fixtures/packages/') + .run(cb); + + function cb(err, stdout) { + stdout = eraseTime(stdout); + expect(stdout).toEqual( + 'Verifying plugins in ' + + path.resolve('./test/fixtures/packages/valid-package.json') + + '\n' + + 'There are no blacklisted plugins in this project\n' + + '' + ); + done(err); + } + }); + + it('default args with invalid dependency', function(done) { + runner({ verbose: false }) + .gulp('--verify', '--cwd ./test/fixtures/packages/') + .run(cb); + + function cb(err, stdout) { + expect(err).toNotEqual(null); + + stdout = eraseTime(stdout); + expect(stdout).toEqual( + 'Verifying plugins in ' + + path.resolve('./test/fixtures/packages/package.json') + '\n' + + 'Blacklisted plugins found in this project:\n' + + 'gulp-blink: deprecated. use `blink` instead.\n' + + '' + ); + done(); + } + }); + +}); diff --git a/test/flags-version.js b/test/flags-version.js index 75105570..4186a7c7 100644 --- a/test/flags-version.js +++ b/test/flags-version.js @@ -1,69 +1,28 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); -var os = require('os'); +var runner = require('gulp-test-tools').gulpRunner; +var eraseTime = require('gulp-test-tools').eraseTime; -var gulp = require('./tool/gulp-cmd'); var cliVersion = require('../package.json').version; var gulpVersion = require('gulp/package.json').version; -var baseDir = path.join(__dirname, '..'); - describe('flag: --version', function() { it('prints the version of CLI and local gulp', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--version', - '--cwd ./test/fixtures/gulpfiles' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual( - 'CLI version: ' + cliVersion + '\n' + - 'Local version: ' + gulpVersion + '\n' + - '' - ); - done(err); - } - }); + runner({ verbose: false }) + .gulp('--version --cwd ./test/fixtures/gulpfiles') + .run(cb); - it('avoids printing "Requiring external module *"', function(done) { - var opts = { cwd: baseDir }; - exec(gulp( - '--version', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-babel.babel.js' - ), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); + function cb(err, stdout) { + stdout = eraseTime(stdout); expect(stdout).toEqual( - 'CLI version: ' + cliVersion + '\n' + - 'Local version: ' + gulpVersion + '\n' + + 'CLI version ' + cliVersion + '\n' + + 'Local version ' + gulpVersion + '\n' + '' ); done(err); } }); - it('should print only CLI version when gulp is not found', function(done) { - var opts = { cwd: baseDir }; - exec(gulp('--version', '--cwd', os.tmpdir()), opts, cb); - - function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toEqual(''); - expect(stdout).toEqual( - 'CLI version: ' + cliVersion + '\n' + - 'Local version: Unknown\n' - ); - done(err); - } - }); - }); diff --git a/test/lib/config-cli-flags.js b/test/lib/config-cli-flags.js deleted file mode 100644 index d78e07a1..00000000 --- a/test/lib/config-cli-flags.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var mergeCliOpts = require('../../lib/shared/config/cli-flags'); - -describe('lib: cli-flags', function() { - - it('Should copy only config props specified to cli flags', function(done) { - var opts = {}; - - var config = { - description: 'DESCRIPTION.', - flags: { - silent: true, - continue: true, - gulpfile: '/path/to/gulpfile', - }, - }; - - var result = mergeCliOpts(opts, config); - expect(result).toEqual({ - silent: true, - continue: true, - }); - expect(result).not.toBe(opts); - done(); - }); - - it('Should not override cli flags with config props', function(done) { - var opts = { - help: false, - depth: 4, - silent: true, - tasks: false, - }; - - var config = { - description: 'DESCRIPTION.', - flags: { - silent: false, - depth: 3, - gulpfile: '/path/to/gulpfile', - }, - }; - - var result = mergeCliOpts(opts, config); - expect(result).toEqual({ - help: false, - depth: 4, - silent: true, - tasks: false, - }); - expect(result).not.toBe(opts); - done(); - }); - - it('Should not cause error if config is empty', function(done) { - var opts = { - help: false, - depth: 4, - silent: true, - tasks: false, - }; - - var config = {}; - - var result = mergeCliOpts(opts, config); - expect(result).toEqual({ - help: false, - depth: 4, - silent: true, - tasks: false, - }); - expect(result).not.toBe(opts); - done(); - }); - -}); - diff --git a/test/lib/format-hrtime.js b/test/lib/format-hrtime.js deleted file mode 100644 index d520c3a1..00000000 --- a/test/lib/format-hrtime.js +++ /dev/null @@ -1,238 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var formatHrtime = require('../../lib/shared/log/format-hrtime'); - -describe('lib: format-hrtime', function() { - describe('should convert hrtime to string: unit is "h"', function() { - it('should be no decimal part if integer part greater than 10', function(done) { - expect(formatHrtime([36000, 100])).toEqual('10 h'); - done(); - }); - - it('should round first decimal place if integer part greather than 10', function(done) { - expect(formatHrtime([36123, 100])).toEqual('10 h'); - expect(formatHrtime([37800, 0])).toEqual('11 h'); - done(); - }); - - it('should print until second decimal place if integer part less than 10', function(done) { - expect(formatHrtime([35100, 100])).toEqual('9.75 h'); - done(); - }); - - it('should round third decimal place if integer part less than 10', function(done) { - expect(formatHrtime([35117, 0])).toEqual('9.75 h'); - expect(formatHrtime([35119, 100])).toEqual('9.76 h'); - done(); - }); - - it('should trim last "0" in decimal part', function(done) { - expect(formatHrtime([32761, 100])).toEqual('9.1 h'); - expect(formatHrtime([32725, 100])).toEqual('9.09 h'); - expect(formatHrtime([32414, 100])).toEqual('9 h'); - done(); - }); - - it('should convert minimum hrtime of unit "h" normally', function(done) { - expect(formatHrtime([3600, 0])).toEqual('1 h'); - done(); - }); - - it('should be no larger unit than `h`', function(done) { - expect(formatHrtime([360123, 100])).toEqual('100 h'); - done(); - }); - }); - - describe('should convert hrtime to string: unit is "min"', function() { - it('should be no decimal part if integer part greater than 10', function(done) { - expect(formatHrtime([600, 100])).toEqual('10 min'); - done(); - }); - - it('should round first decimal place if integer part greather than 10', function(done) { - expect(formatHrtime([624, 100])).toEqual('10 min'); - expect(formatHrtime([630, 0])).toEqual('11 min'); - done(); - }); - - it('should print until second decimal place if integer part less than 10', function(done) { - expect(formatHrtime([599, 100])).toEqual('9.98 min'); - done(); - }); - - it('should round third decimal place if integer part less than 10', function(done) { - expect(formatHrtime([585, 29e7])).toEqual('9.75 min'); - expect(formatHrtime([585, 3e8])).toEqual('9.76 min'); - done(); - }); - - it('should trim last "0" in decimal part', function(done) { - expect(formatHrtime([594, 100])).toEqual('9.9 min'); - expect(formatHrtime([540, 100])).toEqual('9 min'); - done(); - }); - - it('should convert minimum hrtime of unit "min" normally', function(done) { - expect(formatHrtime([60, 0])).toEqual('1 min'); - done(); - }); - - it('should convert maximum hrtime of unit "min" normally', function(done) { - expect(formatHrtime([3599, 999999999])).toEqual('60 min'); - done(); - }); - }); - - describe('should convert hrtime to string: unit is "s"', function() { - it('should be no decimal part if integer part greater than 10', function(done) { - expect(formatHrtime([10, 12e7])).toEqual('10 s'); - done(); - }); - - it('should round first decimal place if integer part greather than 10', function(done) { - expect(formatHrtime([10, 4e8])).toEqual('10 s'); - expect(formatHrtime([10, 5e8])).toEqual('11 s'); - done(); - }); - - it('should print until second decimal place if integer part less than 10', function(done) { - expect(formatHrtime([9, 12e7])).toEqual('9.12 s'); - done(); - }); - - it('should round third decimal place if integer part less than 10', function(done) { - expect(formatHrtime([9, 124e6])).toEqual('9.12 s'); - expect(formatHrtime([9, 125e6])).toEqual('9.13 s'); - done(); - }); - - it('should trim last "0" in decimal part', function(done) { - expect(formatHrtime([9, 100e6])).toEqual('9.1 s'); - expect(formatHrtime([9, 0])).toEqual('9 s'); - done(); - }); - - it('should convert minimum hrtime of unit "s" normally', function(done) { - expect(formatHrtime([1, 0])).toEqual('1 s'); - done(); - }); - - it('should convert maximum hrtime of unit "s" normally', function(done) { - expect(formatHrtime([59, 999999999])).toEqual('60 s'); - done(); - }); - }); - - describe('should convert hrtime to string: unit is "ms"', function() { - it('should be no decimal part if integer part greater than 10', function(done) { - expect(formatHrtime([0, 10123456])).toEqual('10 ms'); - done(); - }); - - it('should round first decimal place if integer part greather than 10', function(done) { - expect(formatHrtime([0, 10423456])).toEqual('10 ms'); - expect(formatHrtime([0, 10500000])).toEqual('11 ms'); - done(); - }); - - it('should print until second decimal place if integer part less than 10', function(done) { - expect(formatHrtime([0, 9123456])).toEqual('9.12 ms'); - done(); - }); - - it('should round third decimal place if integer part less than 10', function(done) { - expect(formatHrtime([0, 9124999])).toEqual('9.12 ms'); - expect(formatHrtime([0, 9125000])).toEqual('9.13 ms'); - done(); - }); - - it('should trim last "0" in decimal part', function(done) { - expect(formatHrtime([0, 9100000])).toEqual('9.1 ms'); - expect(formatHrtime([0, 9000000])).toEqual('9 ms'); - done(); - }); - - it('should convert minimum hrtime of unit "ms" normally', function(done) { - expect(formatHrtime([0, 1000000])).toEqual('1 ms'); - done(); - }); - - it('should convert maximum hrtime of unit "ms" normally', function(done) { - expect(formatHrtime([0, 999999999])).toEqual('1000 ms'); - done(); - }); - }); - - describe('should convert hrtime to string: unit is "μs"', function() { - it('should be no decimal part if integer part greater than 10', function(done) { - expect(formatHrtime([0, 10123])).toEqual('10 μs'); - done(); - }); - - it('should round first decimal place if integer part greather than 10', function(done) { - expect(formatHrtime([0, 10423])).toEqual('10 μs'); - expect(formatHrtime([0, 10500])).toEqual('11 μs'); - done(); - }); - - it('should print until second decimal place if integer part less than 10', function(done) { - expect(formatHrtime([0, 9123])).toEqual('9.12 μs'); - done(); - }); - - it('should round third decimal place if integer part less than 10', function(done) { - expect(formatHrtime([0, 9124])).toEqual('9.12 μs'); - expect(formatHrtime([0, 9125])).toEqual('9.13 μs'); - done(); - }); - - it('should trim last "0" in decimal part', function(done) { - expect(formatHrtime([0, 9100])).toEqual('9.1 μs'); - expect(formatHrtime([0, 9000])).toEqual('9 μs'); - done(); - }); - - it('should convert minimum hrtime of unit "μs" normally', function(done) { - expect(formatHrtime([0, 1000])).toEqual('1 μs'); - done(); - }); - - it('should convert maximum hrtime of unit "μs" normally', function(done) { - expect(formatHrtime([0, 999999])).toEqual('1000 μs'); - done(); - }); - }); - - describe('should convert hrtime to string: unit is "ns"', function() { - it('should convert minimum hrtime of unit "μs" normally', function(done) { - expect(formatHrtime([0, 1])).toEqual('1 ns'); - done(); - }); - - it('should convert maximum hrtime of unit "μs" normally', function(done) { - expect(formatHrtime([0, 999])).toEqual('999 ns'); - done(); - }); - }); - - describe('should convert irregular hrtime to an empty string', function() { - it('should convert non hrtime to an empty string', function(done) { - expect(formatHrtime(1234567890)).toEqual(''); - expect(formatHrtime('1234567890')).toEqual(''); - done(); - }); - - it('should convert bad hrtime to an empty string', function(done) { - expect(formatHrtime(['123', 123])).toEqual(''); - expect(formatHrtime([123, '123'])).toEqual(''); - done(); - }); - - it('should covert zero hrtime to an empty string', function(done) { - expect(formatHrtime([0, 0])).toEqual(''); - done(); - }); - }); -}); diff --git a/test/lib/log-copy-tree.js b/test/lib/log-copy-tree.js deleted file mode 100644 index 4a679a6e..00000000 --- a/test/lib/log-copy-tree.js +++ /dev/null @@ -1,195 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var copyTree = require('../../lib/shared/log/copy-tree'); - -describe('lib: copy-tree', function() { - - var nonConvertingNodeFactory = { - topNode: copyNode, - taskNode: copyNode, - childNode: copyNode, - }; - - it('Should copy an empty tree', function(done) { - var srcTree = {}; - var opts = {}; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual({ nodes: [] }); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree having empty nodes', function(done) { - var srcTree = { - nodes: [ - {}, - { nodes: [] }, - { nodes: [{}, {}] }, - ], - }; - var opts = {}; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual({ - nodes: [ - { nodes: [] }, - { nodes: [] }, - { - nodes: [ - { nodes: [] }, - { nodes: [] }, - ], - }, - ], - }); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree', function(done) { - var srcTree = require('../fixtures/copy-tree'); - var opts = {}; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(srcTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy with no nodeFactory', function(done) { - var srcTree = require('../fixtures/copy-tree'); - var opts = {}; - var newTree = copyTree(srcTree, opts); - expect(newTree).toEqual(srcTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy with no opts and no nodeFactory', function(done) { - var srcTree = require('../fixtures/copy-tree'); - var newTree = copyTree(srcTree); - expect(newTree).toEqual(srcTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - describe('opts.tasksDepth', function() { - - it('Should copy a tree until depth 1 if the specified depth is 0', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-1'); - var opts = { tasksDepth: 0 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree until depth 1 if the specified depth is 1', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-1'); - var opts = { tasksDepth: 1 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree until depth 2 if the specified depth is 2', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-2'); - var opts = { tasksDepth: 2 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree until depth 3 if the specified depth is 3', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-3'); - var opts = { tasksDepth: 3 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree until depth 3 if the specified depth is 4', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-4'); - var opts = { tasksDepth: 4 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a full depth tree if the specified depth is too large', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-4'); - var opts = { tasksDepth: 5 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a tree until depth 1 if the specified depth < 1', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-1'); - var opts = { tasksDepth: -1 }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - it('Should copy a full depth tree if the specified depth is not number', - function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-depth-4'); - var opts = { tasksDepth: null }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - - opts = { tasksDepth: 'A' }; - newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - - }); - - describe('opts.compactTasks', function() { - it('Should output only nodes of which `.branch` are true and those ' + - 'children', function(done) { - var srcTree = require('../fixtures/copy-tree'); - var expectedTree = require('../expected/copy-tree/copy-tree-compact'); - var opts = { compactTasks: true }; - var newTree = copyTree(srcTree, opts, nonConvertingNodeFactory); - expect(newTree).toEqual(expectedTree); - expect(newTree).not.toBe(srcTree); - done(); - }); - }); - -}); - - -function copyNode(node) { - var obj = {}; - Object.keys(node).forEach(function(key) { - obj[key] = node[key]; - }); - return obj; -} - diff --git a/test/lib/make-title.js b/test/lib/make-title.js deleted file mode 100644 index 725d7840..00000000 --- a/test/lib/make-title.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -var expect = require('expect'); - -var makeTitle = require('../../lib/shared/make-title'); - -describe('lib: make-title', function() { - - it('returns the command if no argv passed', function(done) { - var title = makeTitle('gulp'); - - expect(title).toEqual('gulp'); - done(); - }); - - it('returns the command if argv is 0 length', function(done) { - var title = makeTitle('gulp', []); - - expect(title).toEqual('gulp'); - done(); - }); - - it('returns the command and argvs if not empty', function(done) { - var title = makeTitle('gulp', ['build']); - - expect(title).toEqual('gulp build'); - done(); - }); - - it('concats all argv', function(done) { - var title = makeTitle('gulp', ['build', '--prod']); - - expect(title).toEqual('gulp build --prod'); - done(); - }); -}); diff --git a/test/lib/normalize-error.js b/test/lib/normalize-error.js deleted file mode 100644 index d06aef95..00000000 --- a/test/lib/normalize-error.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var normalizeError = require('../../lib/versioned/^4.0.0/normalize-error'); - -describe('lib: normalizeError', function() { - - it('Should return target task and similar tasks if both are included in error message', function(done) { - var err = new Error('Task never defined: task2 - did you mean? task0, task1'); - normalizeError(err); - expect(err).toHaveProperty('task', 'task2'); - expect(err).toHaveProperty('similar', ['task0', 'task1']); - done(); - }); - - it('Should return only target task if similar tasks is not included in error message', function(done) { - var err = new Error('Task never defined: task2'); - normalizeError(err) - expect(err).toHaveProperty('task', 'task2'); - expect(err).not.toHaveProperty('similar'); - done(); - }); - - it('Should return undefined if error is other', function(done) { - var err = new Error('xxx'); - normalizeError(err) - expect(err).not.toHaveProperty('task'); - expect(err).not.toHaveProperty('similar'); - done(); - }); -}); diff --git a/test/logging.js b/test/logging.js index 11d6bd5a..17127996 100644 --- a/test/logging.js +++ b/test/logging.js @@ -1,69 +1,63 @@ 'use strict'; var expect = require('expect'); -var exec = require('child_process').exec; +var child = require('child_process'); describe('logging', function() { it('log-level flag for debug: -LLLL', function(done) { - exec('node ' + __dirname + '/fixtures/logging.js -LLLL', cb); + child.exec('node ' + __dirname + '/fixtures/logging.js -LLLL', cb); function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toMatch('test error'); stdout = stdout.replace(/\\/g, '/').split('\n'); expect(stdout[0]).toMatch('test debug'); expect(stdout[1]).toMatch('test info'); expect(stdout[2]).toMatch('test warn'); + expect(stderr).toMatch('test error'); done(err); } }); it('no log-level flag: defaults to -LLL', function(done) { - exec('node ' + __dirname + '/fixtures/logging.js', cb); + child.exec('node ' + __dirname + '/fixtures/logging.js', cb); function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toMatch('test error'); stdout = stdout.replace(/\\/g, '/').split('\n'); expect(stdout[0]).toMatch('test info'); expect(stdout[1]).toMatch('test warn'); + expect(stderr).toMatch('test error'); done(err); } }); it('log-level flag for info: -LLL', function(done) { - exec('node ' + __dirname + '/fixtures/logging.js -LLL', cb); + child.exec('node ' + __dirname + '/fixtures/logging.js -LLL', cb); function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toMatch('test error'); stdout = stdout.replace(/\\/g, '/').split('\n'); expect(stdout[0]).toMatch('test info'); expect(stdout[1]).toMatch('test warn'); + expect(stderr).toMatch('test error'); done(err); } }); it('log-level flag for warn: -LL', function(done) { - exec('node ' + __dirname + '/fixtures/logging.js -LL', cb); + child.exec('node ' + __dirname + '/fixtures/logging.js -LL', cb); function cb(err, stdout, stderr) { - expect(err).toBeNull(); - expect(stderr).toMatch('test error'); stdout = stdout.replace(/\\/g, '/').split('\n'); expect(stdout[0]).toMatch('test warn'); + expect(stderr).toMatch('test error'); done(err); } }); it('log-level flag for error: -L', function(done) { - exec('node ' + __dirname + '/fixtures/logging.js -L', cb); + child.exec('node ' + __dirname + '/fixtures/logging.js -L', cb); function cb(err, stdout, stderr) { - expect(err).toBeNull(); expect(stderr).toMatch('test error'); - expect(stdout).toEqual(''); done(err); } }); diff --git a/test/sync-task.js b/test/sync-task.js deleted file mode 100644 index 8f1bf677..00000000 --- a/test/sync-task.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var exec = require('child_process').exec; -var path = require('path'); - -var sliceLines = require('./tool/slice-lines'); -var gulp = require('./tool/gulp-cmd'); - -describe('sync-task', function() { - it('should return error code 1 if any tasks did not complete', function(done) { - var opts = { cwd: path.join(__dirname, 'fixtures/gulpfiles') }; - exec(gulp('test6 test7 test8'), opts, cb); - - function cb(err) { - expect(err).not.toBeNull(); - expect(err.code).toEqual(1); - done(); - } - }); - - it('should log tasks which did not complete', function(done) { - var opts = { cwd: path.join(__dirname, 'fixtures/gulpfiles') }; - exec(gulp('test6 test7 test8'), opts, cb); - - function cb(err, stdout) { - expect(sliceLines(stdout, 5, 7)).toEqual( - 'The following tasks did not complete: test7, test8\n' + - 'Did you forget to signal async completion?' - ); - done(); - } - }); - - it('should not log false positive in case of parallel failure', function(done) { - var opts = { cwd: path.join(__dirname, '..') }; - exec(gulp( - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js' - ), opts, cb); - - function cb(err, stdout) { - expect(stdout).not.toMatch('The following tasks did not complete:'); - done(); - } - }); - - it('should not log false positive in case of parallel failure in continue mode', function(done) { - var opts = { cwd: path.join(__dirname, '..') }; - exec(gulp( - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js' - ), opts, cb); - - function cb(err, stdout) { - expect(stdout).not.toMatch('The following tasks did not complete:'); - done(); - } - }); - - it('should log non-completing task alongside a failure in continue mode', function(done) { - var opts = { cwd: path.join(__dirname, '..') }; - exec(gulp( - '--continue', - '--gulpfile ./test/fixtures/gulpfiles/gulpfile-parallel-failure.js', - 'broken' - ), opts, cb); - - function cb(err, stdout) { - expect(stdout).toMatch('The following tasks did not complete: broken, notCompleting1\n'); - done(); - } - }); -}); diff --git a/test/lib/task-tree.js b/test/taskTree.js similarity index 73% rename from test/lib/task-tree.js rename to test/taskTree.js index ffe4dcad..8345c7a9 100644 --- a/test/lib/task-tree.js +++ b/test/taskTree.js @@ -2,12 +2,12 @@ var expect = require('expect'); -var taskTree = require('../../lib/versioned/^3.7.0/task-tree'); +var taskTree = require('../lib/versioned/^3.7.0/taskTree'); -describe('lib: taskTree', function() { +describe('taskTree', function() { it('forms a tree properly', function(done) { - expect(taskTree).not.toBeNull(); // Lol shutup jshint + expect(taskTree).toExist(); // Lol shutup jshint var tasks = { test: { @@ -26,22 +26,19 @@ describe('lib: taskTree', function() { nodes: [ { label: 'test', - type: 'task', nodes: [ - { label: 'dep1', type: 'task', nodes: [] }, - { label: 'dep2', type: 'task', nodes: [] }, + { label: 'dep1', nodes: [], }, + { label: 'dep2', nodes: [], }, ], }, { label: 'test2', - type: 'task', nodes: [ - { label: 'dep3', type: 'task', nodes: [] }, + { label: 'dep3', nodes: [], }, ], }, { label: 'test3', - type: 'task', nodes: [], }, ], @@ -69,40 +66,33 @@ describe('lib: taskTree', function() { nodes: [ { label: 'test', - type: 'task', nodes: [ { label: 'test2', - type: 'task', nodes: [ { label: 'test3', - type: 'task', nodes: [], }, ], }, { label: 'test3', - type: 'task', nodes: [], }, ], }, { label: 'test2', - type: 'task', nodes: [ { label: 'test3', - type: 'task', nodes: [], }, ], }, { label: 'test3', - type: 'task', nodes: [], }, ], diff --git a/test/tool/erase-lapse.js b/test/tool/erase-lapse.js deleted file mode 100644 index f1345e2d..00000000 --- a/test/tool/erase-lapse.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function(text) { - return (text + '\n') - .replace(/ after [0-9.]+ (s|ms|μs|min)(\r\n|\r|\n)/g, ' after ?\n') - .slice(0, -1); -}; diff --git a/test/tool/erase-time.js b/test/tool/erase-time.js deleted file mode 100644 index 444c4412..00000000 --- a/test/tool/erase-time.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function(text) { - return ('\n' + text).replace(/(\r\n|\r|\n)\[[0-9:]{8}\] /g, '\n').slice(1); -}; diff --git a/test/tool/gulp-cmd.js b/test/tool/gulp-cmd.js deleted file mode 100644 index 87540be1..00000000 --- a/test/tool/gulp-cmd.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var path = require('path'); - -function gulp(/* ... */) { - var arr = Array.prototype.slice.apply(arguments); - arr.unshift('node ' + path.join(__dirname, '../../bin/gulp.js')); - return arr.join(' '); -} -gulp.debug = function(/* ... */) { - var s = gulp.apply(null, arguments); - console.log(s); - return s; -} - -module.exports = gulp; diff --git a/test/tool/slice-lines.js b/test/tool/slice-lines.js deleted file mode 100644 index 4431d3c8..00000000 --- a/test/tool/slice-lines.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var eraseLapse = require('./erase-lapse'); -var eraseTime = require('./erase-time'); - -function sliceLines(text, start, end) { - text = eraseLapse(eraseTime(text)); - return text.split('\n').slice(start, end).join('\n'); -} - -module.exports = sliceLines; diff --git a/test/window-extended-length-paths.js b/test/window-extended-length-paths.js deleted file mode 100644 index e89b0f4e..00000000 --- a/test/window-extended-length-paths.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -var expect = require('expect'); -var os = require('os'); -var path = require('path'); - -var childProcess = require('child_process'); -var exec = childProcess.exec; - -var eraseTime = require('./tool/erase-time'); -var eraseLapse = require('./tool/erase-lapse'); -var tildify = require('../lib/shared/tildify'); - -var gulpfileDir = path.resolve(__dirname, 'fixtures/gulpfiles'); -var gulpfilePath = path.resolve(gulpfileDir, 'gulpfile.js'); - -var gulpJsPath = '\\\\?\\' + path.resolve(__dirname, '../bin/gulp.js'); - -describe('windows extended length paths', function() { - it('Should run normaly even if using \'\\\\?\\\'prefix in paths', function(done) { - // It seems like Node 24 broke support for this launching an entry point - if (os.platform() !== 'win32' || process.versions.node.startsWith("24.")) { - this.skip(); - return; - } - - var cmd = ['node', gulpJsPath, '--no-color', '--gulpfile', gulpfilePath].join(' '); - - exec(cmd, function cb(err, stdout, stderr) { - expect(err).toEqual(null); - expect(stderr).toEqual(''); - - var workingDir = tildify(gulpfileDir); - var usingGulpfile = tildify(gulpfilePath); - - stdout = eraseLapse(eraseTime(stdout)); - expect(stdout).toEqual('' + - 'Working directory changed to ' + workingDir + '\n' + - 'Using gulpfile ' + usingGulpfile + '\n' + - 'Starting \'default\'...\n' + - 'Starting \'test1\'...\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'test1\' after ?\n' + - 'Starting \'test3\'...\n' + - 'Starting \'described\'...\n' + - 'Finished \'described\' after ?\n' + - 'Finished \'test3\' after ?\n' + - 'Starting \'noop\'...\n' + - 'Finished \'noop\' after ?\n' + - 'Finished \'default\' after ?\n' + - ''); - done(); - }); - }); -});