Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
71c01821
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71c01821
编写于
2月 27, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use git index in hygiene
上级
50810920
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
9 deletion
+67
-9
build/gulpfile.hygiene.js
build/gulpfile.hygiene.js
+56
-9
package.json
package.json
+1
-0
yarn.lock
yarn.lock
+10
-0
未找到文件。
build/gulpfile.hygiene.js
浏览文件 @
71c01821
...
...
@@ -12,9 +12,11 @@ const gulptslint = require('gulp-tslint');
const
gulpeslint
=
require
(
'
gulp-eslint
'
);
const
tsfmt
=
require
(
'
typescript-formatter
'
);
const
tslint
=
require
(
'
tslint
'
);
const
VinylFile
=
require
(
'
vinyl
'
);
const
vfs
=
require
(
'
vinyl-fs
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
const
pall
=
require
(
'
p-all
'
);
/**
* Hygiene works by creating cascading subsets of all our files and
...
...
@@ -157,7 +159,7 @@ gulp.task('tslint', () => {
.
pipe
(
gulptslint
.
default
.
report
(
options
));
});
const
hygiene
=
exports
.
hygiene
=
(
some
,
options
)
=>
{
function
hygiene
(
some
,
options
)
{
options
=
options
||
{};
let
errorCount
=
0
;
...
...
@@ -279,7 +281,15 @@ const hygiene = exports.hygiene = (some, options) => {
this
.
emit
(
'
data
'
,
file
);
});
const
result
=
vfs
.
src
(
some
||
all
,
{
base
:
'
.
'
,
follow
:
true
,
allowEmpty
:
true
})
let
input
;
if
(
Array
.
isArray
(
some
)
||
typeof
some
===
'
string
'
||
!
some
)
{
input
=
vfs
.
src
(
some
||
all
,
{
base
:
'
.
'
,
follow
:
true
,
allowEmpty
:
true
});
}
else
{
input
=
some
;
}
const
result
=
input
.
pipe
(
filter
(
f
=>
!
f
.
stat
.
isDirectory
()))
.
pipe
(
filter
(
eolFilter
))
.
pipe
(
options
.
skipEOL
?
es
.
through
()
:
eol
)
...
...
@@ -331,9 +341,39 @@ const hygiene = exports.hygiene = (some, options) => {
this
.
emit
(
'
end
'
);
}
}));
};
}
function
createGitIndexVinyls
(
paths
)
{
const
cp
=
require
(
'
child_process
'
);
const
repositoryPath
=
process
.
cwd
();
const
fns
=
paths
.
map
(
relativePath
=>
()
=>
new
Promise
((
c
,
e
)
=>
{
const
fullPath
=
path
.
join
(
repositoryPath
,
relativePath
);
fs
.
stat
(
fullPath
,
(
err
,
stat
)
=>
{
if
(
err
)
{
return
e
(
err
);
}
cp
.
exec
(
`git show :
${
relativePath
}
`
,
{
maxBuffer
:
2000
*
1024
,
encoding
:
'
buffer
'
},
(
err
,
out
)
=>
{
if
(
err
)
{
return
e
(
err
);
}
c
(
new
VinylFile
({
path
:
fullPath
,
base
:
repositoryPath
,
contents
:
out
,
stat
}));
});
});
}));
return
pall
(
fns
,
{
concurrency
:
4
});
}
gulp
.
task
(
'
hygiene
'
,
()
=>
hygiene
(
''
));
gulp
.
task
(
'
hygiene
'
,
()
=>
hygiene
());
// this allows us to run hygiene as a git pre-commit hook
if
(
require
.
main
===
module
)
{
...
...
@@ -360,6 +400,7 @@ if (require.main === module) {
console
.
error
();
console
.
error
(
err
);
process
.
exit
(
1
);
return
;
}
const
some
=
out
...
...
@@ -367,11 +408,17 @@ if (require.main === module) {
.
filter
(
l
=>
!!
l
);
if
(
some
.
length
>
0
)
{
hygiene
(
some
,
{
skipEOL
:
skipEOL
}).
on
(
'
error
'
,
err
=>
{
console
.
error
();
console
.
error
(
err
);
process
.
exit
(
1
);
});
console
.
log
(
'
Reading git index versions...
'
);
createGitIndexVinyls
(
some
)
.
then
(
vinyls
=>
new
Promise
((
c
,
e
)
=>
hygiene
(
es
.
readArray
(
vinyls
),
{
skipEOL
:
skipEOL
})
.
on
(
'
end
'
,
()
=>
c
())
.
on
(
'
error
'
,
e
)))
.
catch
(
err
=>
{
console
.
error
();
console
.
error
(
err
);
process
.
exit
(
1
);
});
}
});
});
...
...
package.json
浏览文件 @
71c01821
...
...
@@ -104,6 +104,7 @@
"
mocha
"
:
"
^2.2.5
"
,
"
object-assign
"
:
"
^4.0.1
"
,
"
optimist
"
:
"
0.3.5
"
,
"
p-all
"
:
"
^1.0.0
"
,
"
pump
"
:
"
^1.0.1
"
,
"
queue
"
:
"
3.0.6
"
,
"
remap-istanbul
"
:
"
^0.6.4
"
,
...
...
yarn.lock
浏览文件 @
71c01821
...
...
@@ -4160,6 +4160,12 @@ osenv@^0.1.3:
os-homedir "^1.0.0"
os-tmpdir "^1.0.0"
p-all@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-all/-/p-all-1.0.0.tgz#93bdf53a55a23821fdfa98b4174a99bf7f31df8d"
dependencies:
p-map "^1.0.0"
p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
...
...
@@ -4176,6 +4182,10 @@ p-locate@^2.0.0:
dependencies:
p-limit "^1.1.0"
p-map@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/p-map/-/p-map-1.2.0.tgz#e4e94f311eabbc8633a1e79908165fca26241b6b"
p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录