Skip to content

Commit

Permalink
添加了expect任务,准备发布1.0.0版本
Browse files Browse the repository at this point in the history
  • Loading branch information
raintean committed Feb 6, 2018
1 parent c8324e1 commit ed8d05a
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 7 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = {
minijs: require('./tasks/minijs'),
minicss: require('./tasks/minicss'),
typscript: require('./tasks/typescript'),
npm: require('./tasks/npm')
npm: require('./tasks/npm'),
expect: require('./tasks/expect')
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-eztasks",
"version": "0.0.9",
"version": "1.0.0",
"description": "common gulp tasks set",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -34,9 +34,10 @@
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"typescript": "^2.6.2"
"run-sequence": "^2.2.1"
},
"devDependencies": {
"gulp": "^3.9.1"
"gulp": "^3.9.1",
"typescript": "^2.7.1"
}
}
49 changes: 49 additions & 0 deletions tasks/expect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* 等待文件存在,然后启动gulp任务
* Created by demon on 16/5/14.
*/
var run = require('run-sequence');
var watch = require('gulp-watch');
var path = require('path');
var fs = require('fs');

/**
* 压缩指定的js文件
* @param filesToWait 需要等待的文件列表(非glob)
* @param tasks 任务列表,run-sequence形式
* @returns {Function} gulp任务(Task)
*/
module.exports = function () {
var args = Array.prototype.slice.call(arguments);
var filesToWait = args[0];
args.splice(0, 1);
var tasks = args;

return function (done) {
var remainingFiles = [];
for (var i = 0; i < filesToWait.length; i++) {
var file = filesToWait[i];
var filePath = path.isAbsolute(file) ? file : path.join(process.cwd(), file);
//如果文件不存在,则添加等待
try {
fs.accessSync(filePath)
} catch (e) {
remainingFiles.push(path.join(process.cwd(), file))
}
}

var watcher = watch(filesToWait, function (file) {
if (file.event === 'add') {
if (remainingFiles.indexOf(file.path) >= 0) {
remainingFiles.splice(remainingFiles.indexOf(file.path), 1)
}

if (remainingFiles.length <= 0) {
tasks.push(done);
run.apply(this, tasks);
watcher.close()
}
}
});
}
};
83 changes: 80 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"

ansi-cyan@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ansi-cyan/-/ansi-cyan-0.1.1.tgz#538ae528af8982f28ae30d86f2f17456d2609873"
dependencies:
ansi-wrap "0.1.0"

ansi-gray@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251"
dependencies:
ansi-wrap "0.1.0"

ansi-red@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c"
dependencies:
ansi-wrap "0.1.0"

ansi-regex@^0.2.0, ansi-regex@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9"
Expand All @@ -58,6 +76,10 @@ ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"

[email protected]:
version "0.1.0"
resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf"

anymatch@^1.3.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a"
Expand All @@ -80,6 +102,13 @@ are-we-there-yet@~1.1.2:
delegates "^1.0.0"
readable-stream "^2.0.6"

arr-diff@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-1.1.0.tgz#687c32758163588fef7de7b36fabe495eb1a399a"
dependencies:
arr-flatten "^1.0.1"
array-slice "^0.2.3"

arr-diff@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
Expand All @@ -90,6 +119,10 @@ arr-flatten@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"

arr-union@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-2.1.0.tgz#20f9eab5ec70f5c7d215b1077b1c39161d292c7d"

array-differ@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031"
Expand All @@ -102,6 +135,10 @@ array-find-index@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"

array-slice@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5"

array-slice@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-1.1.0.tgz#e368ea15f89bc7069f7ffb89aec3a6c7d4ac22d4"
Expand Down Expand Up @@ -392,6 +429,10 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"

color-support@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"

combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
Expand Down Expand Up @@ -647,6 +688,12 @@ expand-tilde@^2.0.2:
dependencies:
homedir-polyfill "^1.0.1"

extend-shallow@^1.1.2:
version "1.1.4"
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-1.1.4.tgz#19d6bf94dfc09d76ba711f39b872d21ff4dd9071"
dependencies:
kind-of "^1.1.0"

extend-shallow@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
Expand Down Expand Up @@ -678,6 +725,14 @@ fancy-log@^1.1.0:
chalk "^1.1.1"
time-stamp "^1.0.0"

fancy-log@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.2.tgz#f41125e3d84f2e7d89a43d06d958c8f78be16be1"
dependencies:
ansi-gray "^0.1.1"
color-support "^1.1.3"
time-stamp "^1.0.0"

filename-regex@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"
Expand Down Expand Up @@ -1439,6 +1494,10 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.10.0"

kind-of@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44"

kind-of@^3.0.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
Expand Down Expand Up @@ -2063,6 +2122,16 @@ pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"

plugin-error@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-0.1.2.tgz#3b9bb3335ccf00f425e07437e19276967da47ace"
dependencies:
ansi-cyan "^0.1.1"
ansi-red "^0.1.1"
arr-diff "^1.0.1"
arr-union "^2.0.1"
extend-shallow "^1.1.2"

preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
Expand Down Expand Up @@ -2252,6 +2321,14 @@ rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1:
dependencies:
glob "^7.0.5"

run-sequence@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/run-sequence/-/run-sequence-2.2.1.tgz#1ce643da36fd8c7ea7e1a9329da33fc2b8898495"
dependencies:
chalk "^1.1.3"
fancy-log "^1.3.2"
plugin-error "^0.1.2"

safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
Expand Down Expand Up @@ -2563,9 +2640,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"

typescript@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
typescript@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359"

uglify-js@^3.0.5:
version "3.2.2"
Expand Down

0 comments on commit ed8d05a

Please sign in to comment.