Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
33718984
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
33718984
编写于
9月 22, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix lint errors
上级
448115e4
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
177 addition
and
181 deletion
+177
-181
build/gulpfile.hygiene.js
build/gulpfile.hygiene.js
+22
-24
build/hygiene.js
build/hygiene.js
+155
-157
未找到文件。
build/gulpfile.hygiene.js
浏览文件 @
33718984
...
...
@@ -3,40 +3,38 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"
use strict
"
;
const
gulp
=
require
(
'
gulp
'
);
const
filter
=
require
(
'
gulp-filter
'
);
const
es
=
require
(
'
event-stream
'
);
const
gulpeslint
=
require
(
'
gulp-eslint
'
);
const
vfs
=
require
(
'
vinyl-fs
'
);
const
path
=
require
(
'
path
'
);
const
task
=
require
(
'
./lib/task
'
);
const
{
all
,
jsHygieneFilter
,
tsHygieneFilter
,
hygiene
}
=
require
(
'
./hygiene
'
);
const
gulp
=
require
(
"
gulp
"
);
const
filter
=
require
(
"
gulp-filter
"
);
const
es
=
require
(
"
event-stream
"
);
const
gulpeslint
=
require
(
"
gulp-eslint
"
);
const
vfs
=
require
(
"
vinyl-fs
"
);
const
path
=
require
(
"
path
"
);
const
task
=
require
(
"
./lib/task
"
);
const
{
all
,
jsHygieneFilter
,
tsHygieneFilter
,
hygiene
}
=
require
(
"
./hygiene
"
);
gulp
.
task
(
"
eslint
"
,
()
=>
{
gulp
.
task
(
'
eslint
'
,
()
=>
{
return
vfs
.
src
(
all
,
{
base
:
"
.
"
,
follow
:
true
,
allowEmpty
:
true
})
.
src
(
all
,
{
base
:
'
.
'
,
follow
:
true
,
allowEmpty
:
true
})
.
pipe
(
filter
(
jsHygieneFilter
.
concat
(
tsHygieneFilter
)))
.
pipe
(
gulpeslint
({
configFile
:
"
.eslintrc.json
"
,
rulePaths
:
[
"
./build/lib/eslint
"
],
configFile
:
'
.eslintrc.json
'
,
rulePaths
:
[
'
./build/lib/eslint
'
],
})
)
.
pipe
(
gulpeslint
.
formatEach
(
"
compact
"
))
.
pipe
(
gulpeslint
.
formatEach
(
'
compact
'
))
.
pipe
(
gulpeslint
.
results
((
results
)
=>
{
if
(
results
.
warningCount
>
0
||
results
.
errorCount
>
0
)
{
throw
new
Error
(
"
eslint failed with warnings and/or errors
"
);
throw
new
Error
(
'
eslint failed with warnings and/or errors
'
);
}
})
);
});
function
checkPackageJSON
(
actualPath
)
{
const
actual
=
require
(
path
.
join
(
__dirname
,
"
..
"
,
actualPath
));
const
rootPackageJSON
=
require
(
"
../package.json
"
);
const
actual
=
require
(
path
.
join
(
__dirname
,
'
..
'
,
actualPath
));
const
rootPackageJSON
=
require
(
'
../package.json
'
);
for
(
let
depName
in
actual
.
dependencies
)
{
const
depVersion
=
actual
.
dependencies
[
depName
];
...
...
@@ -47,24 +45,24 @@ function checkPackageJSON(actualPath) {
}
if
(
depVersion
!==
rootDepVersion
)
{
this
.
emit
(
"
error
"
,
'
error
'
,
`The dependency
${
depName
}
in '
${
actualPath
}
' (
${
depVersion
}
) is different than in the root package.json (
${
rootDepVersion
}
)`
);
}
}
}
const
checkPackageJSONTask
=
task
.
define
(
"
check-package-json
"
,
()
=>
{
return
gulp
.
src
(
"
package.json
"
).
pipe
(
const
checkPackageJSONTask
=
task
.
define
(
'
check-package-json
'
,
()
=>
{
return
gulp
.
src
(
'
package.json
'
).
pipe
(
es
.
through
(
function
()
{
checkPackageJSON
.
call
(
this
,
"
remote/package.json
"
);
checkPackageJSON
.
call
(
this
,
"
remote/web/package.json
"
);
checkPackageJSON
.
call
(
this
,
'
remote/package.json
'
);
checkPackageJSON
.
call
(
this
,
'
remote/web/package.json
'
);
})
);
});
gulp
.
task
(
checkPackageJSONTask
);
gulp
.
task
(
"
hygiene
"
,
'
hygiene
'
,
task
.
series
(
checkPackageJSONTask
,
()
=>
hygiene
())
);
build/hygiene.js
浏览文件 @
33718984
...
...
@@ -3,17 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"
use strict
"
;
const
filter
=
require
(
"
gulp-filter
"
);
const
es
=
require
(
"
event-stream
"
);
const
gulpeslint
=
require
(
"
gulp-eslint
"
);
const
tsfmt
=
require
(
"
typescript-formatter
"
);
const
VinylFile
=
require
(
"
vinyl
"
);
const
vfs
=
require
(
"
vinyl-fs
"
);
const
path
=
require
(
"
path
"
);
const
fs
=
require
(
"
fs
"
);
const
pall
=
require
(
"
p-all
"
);
const
filter
=
require
(
'
gulp-filter
'
);
const
es
=
require
(
'
event-stream
'
);
const
gulpeslint
=
require
(
'
gulp-eslint
'
);
const
tsfmt
=
require
(
'
typescript-formatter
'
);
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
...
...
@@ -25,159 +23,159 @@ const pall = require("p-all");
*/
const
all
=
[
"
*
"
,
"
build/**/*
"
,
"
extensions/**/*
"
,
"
scripts/**/*
"
,
"
src/**/*
"
,
"
test/**/*
"
,
"
!test/**/out/**
"
,
"
!**/node_modules/**
"
,
'
*
'
,
'
build/**/*
'
,
'
extensions/**/*
'
,
'
scripts/**/*
'
,
'
src/**/*
'
,
'
test/**/*
'
,
'
!test/**/out/**
'
,
'
!**/node_modules/**
'
,
];
module
.
exports
.
all
=
all
;
const
indentationFilter
=
[
"
**
"
,
'
**
'
,
// except specific files
"
!**/ThirdPartyNotices.txt
"
,
"
!**/LICENSE.{txt,rtf}
"
,
"
!LICENSES.chromium.html
"
,
"
!**/LICENSE
"
,
"
!src/vs/nls.js
"
,
"
!src/vs/nls.build.js
"
,
"
!src/vs/css.js
"
,
"
!src/vs/css.build.js
"
,
"
!src/vs/loader.js
"
,
"
!src/vs/base/common/insane/insane.js
"
,
"
!src/vs/base/common/marked/marked.js
"
,
"
!src/vs/base/node/terminateProcess.sh
"
,
"
!src/vs/base/node/cpuUsage.sh
"
,
"
!test/unit/assert.js
"
,
'
!**/ThirdPartyNotices.txt
'
,
'
!**/LICENSE.{txt,rtf}
'
,
'
!LICENSES.chromium.html
'
,
'
!**/LICENSE
'
,
'
!src/vs/nls.js
'
,
'
!src/vs/nls.build.js
'
,
'
!src/vs/css.js
'
,
'
!src/vs/css.build.js
'
,
'
!src/vs/loader.js
'
,
'
!src/vs/base/common/insane/insane.js
'
,
'
!src/vs/base/common/marked/marked.js
'
,
'
!src/vs/base/node/terminateProcess.sh
'
,
'
!src/vs/base/node/cpuUsage.sh
'
,
'
!test/unit/assert.js
'
,
// except specific folders
"
!test/automation/out/**
"
,
"
!test/smoke/out/**
"
,
"
!extensions/typescript-language-features/test-workspace/**
"
,
"
!extensions/vscode-api-tests/testWorkspace/**
"
,
"
!extensions/vscode-api-tests/testWorkspace2/**
"
,
"
!build/monaco/**
"
,
"
!build/win32/**
"
,
'
!test/automation/out/**
'
,
'
!test/smoke/out/**
'
,
'
!extensions/typescript-language-features/test-workspace/**
'
,
'
!extensions/vscode-api-tests/testWorkspace/**
'
,
'
!extensions/vscode-api-tests/testWorkspace2/**
'
,
'
!build/monaco/**
'
,
'
!build/win32/**
'
,
// except multiple specific files
"
!**/package.json
"
,
"
!**/yarn.lock
"
,
"
!**/yarn-error.log
"
,
'
!**/package.json
'
,
'
!**/yarn.lock
'
,
'
!**/yarn-error.log
'
,
// except multiple specific folders
"
!**/codicon/**
"
,
"
!**/fixtures/**
"
,
"
!**/lib/**
"
,
"
!extensions/**/out/**
"
,
"
!extensions/**/snippets/**
"
,
"
!extensions/**/syntaxes/**
"
,
"
!extensions/**/themes/**
"
,
"
!extensions/**/colorize-fixtures/**
"
,
'
!**/codicon/**
'
,
'
!**/fixtures/**
'
,
'
!**/lib/**
'
,
'
!extensions/**/out/**
'
,
'
!extensions/**/snippets/**
'
,
'
!extensions/**/syntaxes/**
'
,
'
!extensions/**/themes/**
'
,
'
!extensions/**/colorize-fixtures/**
'
,
// except specific file types
"
!src/vs/*/**/*.d.ts
"
,
"
!src/typings/**/*.d.ts
"
,
"
!extensions/**/*.d.ts
"
,
"
!**/*.{svg,exe,png,bmp,scpt,bat,cmd,cur,ttf,woff,eot,md,ps1,template,yaml,yml,d.ts.recipe,ico,icns,plist}
"
,
"
!build/{lib,download,darwin}/**/*.js
"
,
"
!build/**/*.sh
"
,
"
!build/azure-pipelines/**/*.js
"
,
"
!build/azure-pipelines/**/*.config
"
,
"
!**/Dockerfile
"
,
"
!**/Dockerfile.*
"
,
"
!**/*.Dockerfile
"
,
"
!**/*.dockerfile
"
,
"
!extensions/markdown-language-features/media/*.js
"
,
'
!src/vs/*/**/*.d.ts
'
,
'
!src/typings/**/*.d.ts
'
,
'
!extensions/**/*.d.ts
'
,
'
!**/*.{svg,exe,png,bmp,scpt,bat,cmd,cur,ttf,woff,eot,md,ps1,template,yaml,yml,d.ts.recipe,ico,icns,plist}
'
,
'
!build/{lib,download,darwin}/**/*.js
'
,
'
!build/**/*.sh
'
,
'
!build/azure-pipelines/**/*.js
'
,
'
!build/azure-pipelines/**/*.config
'
,
'
!**/Dockerfile
'
,
'
!**/Dockerfile.*
'
,
'
!**/*.Dockerfile
'
,
'
!**/*.dockerfile
'
,
'
!extensions/markdown-language-features/media/*.js
'
,
];
const
copyrightFilter
=
[
"
**
"
,
"
!**/*.desktop
"
,
"
!**/*.json
"
,
"
!**/*.html
"
,
"
!**/*.template
"
,
"
!**/*.md
"
,
"
!**/*.bat
"
,
"
!**/*.cmd
"
,
"
!**/*.ico
"
,
"
!**/*.icns
"
,
"
!**/*.xml
"
,
"
!**/*.sh
"
,
"
!**/*.txt
"
,
"
!**/*.xpm
"
,
"
!**/*.opts
"
,
"
!**/*.disabled
"
,
"
!**/*.code-workspace
"
,
"
!**/*.js.map
"
,
"
!build/**/*.init
"
,
"
!resources/linux/snap/snapcraft.yaml
"
,
"
!resources/linux/snap/electron-launch
"
,
"
!resources/win32/bin/code.js
"
,
"
!resources/web/code-web.js
"
,
"
!resources/completions/**
"
,
"
!extensions/markdown-language-features/media/highlight.css
"
,
"
!extensions/html-language-features/server/src/modes/typescript/*
"
,
"
!extensions/*/server/bin/*
"
,
"
!src/vs/editor/test/node/classification/typescript-test.ts
"
,
'
**
'
,
'
!**/*.desktop
'
,
'
!**/*.json
'
,
'
!**/*.html
'
,
'
!**/*.template
'
,
'
!**/*.md
'
,
'
!**/*.bat
'
,
'
!**/*.cmd
'
,
'
!**/*.ico
'
,
'
!**/*.icns
'
,
'
!**/*.xml
'
,
'
!**/*.sh
'
,
'
!**/*.txt
'
,
'
!**/*.xpm
'
,
'
!**/*.opts
'
,
'
!**/*.disabled
'
,
'
!**/*.code-workspace
'
,
'
!**/*.js.map
'
,
'
!build/**/*.init
'
,
'
!resources/linux/snap/snapcraft.yaml
'
,
'
!resources/linux/snap/electron-launch
'
,
'
!resources/win32/bin/code.js
'
,
'
!resources/web/code-web.js
'
,
'
!resources/completions/**
'
,
'
!extensions/markdown-language-features/media/highlight.css
'
,
'
!extensions/html-language-features/server/src/modes/typescript/*
'
,
'
!extensions/*/server/bin/*
'
,
'
!src/vs/editor/test/node/classification/typescript-test.ts
'
,
];
const
jsHygieneFilter
=
[
"
src/**/*.js
"
,
"
build/gulpfile.*.js
"
,
"
!src/vs/loader.js
"
,
"
!src/vs/css.js
"
,
"
!src/vs/nls.js
"
,
"
!src/vs/css.build.js
"
,
"
!src/vs/nls.build.js
"
,
"
!src/**/insane.js
"
,
"
!src/**/marked.js
"
,
"
!**/test/**
"
,
'
src/**/*.js
'
,
'
build/gulpfile.*.js
'
,
'
!src/vs/loader.js
'
,
'
!src/vs/css.js
'
,
'
!src/vs/nls.js
'
,
'
!src/vs/css.build.js
'
,
'
!src/vs/nls.build.js
'
,
'
!src/**/insane.js
'
,
'
!src/**/marked.js
'
,
'
!**/test/**
'
,
];
module
.
exports
.
jsHygieneFilter
=
jsHygieneFilter
;
const
tsHygieneFilter
=
[
"
src/**/*.ts
"
,
"
test/**/*.ts
"
,
"
extensions/**/*.ts
"
,
"
!**/fixtures/**
"
,
"
!**/typings/**
"
,
"
!**/node_modules/**
"
,
"
!extensions/typescript-basics/test/colorize-fixtures/**
"
,
"
!extensions/vscode-api-tests/testWorkspace/**
"
,
"
!extensions/vscode-api-tests/testWorkspace2/**
"
,
"
!extensions/**/*.test.ts
"
,
"
!extensions/html-language-features/server/lib/jquery.d.ts
"
,
'
src/**/*.ts
'
,
'
test/**/*.ts
'
,
'
extensions/**/*.ts
'
,
'
!**/fixtures/**
'
,
'
!**/typings/**
'
,
'
!**/node_modules/**
'
,
'
!extensions/typescript-basics/test/colorize-fixtures/**
'
,
'
!extensions/vscode-api-tests/testWorkspace/**
'
,
'
!extensions/vscode-api-tests/testWorkspace2/**
'
,
'
!extensions/**/*.test.ts
'
,
'
!extensions/html-language-features/server/lib/jquery.d.ts
'
,
];
module
.
exports
.
tsHygieneFilter
=
tsHygieneFilter
;
const
copyrightHeaderLines
=
[
"
/*---------------------------------------------------------------------------------------------
"
,
"
* Copyright (c) Microsoft Corporation. All rights reserved.
"
,
"
* Licensed under the MIT License. See License.txt in the project root for license information.
"
,
"
*--------------------------------------------------------------------------------------------*/
"
,
'
/*---------------------------------------------------------------------------------------------
'
,
'
* Copyright (c) Microsoft Corporation. All rights reserved.
'
,
'
* Licensed under the MIT License. See License.txt in the project root for license information.
'
,
'
*--------------------------------------------------------------------------------------------*/
'
,
];
function
hygiene
(
some
)
{
let
errorCount
=
0
;
const
productJson
=
es
.
through
(
function
(
file
)
{
const
product
=
JSON
.
parse
(
file
.
contents
.
toString
(
"
utf8
"
));
const
product
=
JSON
.
parse
(
file
.
contents
.
toString
(
'
utf8
'
));
if
(
product
.
extensionsGallery
)
{
console
.
error
(
'
product.json: Contains "extensionsGallery"
'
);
console
.
error
(
`product.json: Contains 'extensionsGallery'`
);
errorCount
++
;
}
this
.
emit
(
"
data
"
,
file
);
this
.
emit
(
'
data
'
,
file
);
});
const
indentation
=
es
.
through
(
function
(
file
)
{
const
lines
=
file
.
contents
.
toString
(
"
utf8
"
).
split
(
/
\r\n
|
\r
|
\n
/
);
const
lines
=
file
.
contents
.
toString
(
'
utf8
'
).
split
(
/
\r\n
|
\r
|
\n
/
);
file
.
__lines
=
lines
;
lines
.
forEach
((
line
,
i
)
=>
{
...
...
@@ -189,13 +187,13 @@ function hygiene(some) {
// block comment using an extra space
}
else
{
console
.
error
(
file
.
relative
+
"
(
"
+
(
i
+
1
)
+
"
,1): Bad whitespace indentation
"
file
.
relative
+
'
(
'
+
(
i
+
1
)
+
'
,1): Bad whitespace indentation
'
);
errorCount
++
;
}
});
this
.
emit
(
"
data
"
,
file
);
this
.
emit
(
'
data
'
,
file
);
});
const
copyrights
=
es
.
through
(
function
(
file
)
{
...
...
@@ -203,18 +201,18 @@ function hygiene(some) {
for
(
let
i
=
0
;
i
<
copyrightHeaderLines
.
length
;
i
++
)
{
if
(
lines
[
i
]
!==
copyrightHeaderLines
[
i
])
{
console
.
error
(
file
.
relative
+
"
: Missing or bad copyright statement
"
);
console
.
error
(
file
.
relative
+
'
: Missing or bad copyright statement
'
);
errorCount
++
;
break
;
}
}
this
.
emit
(
"
data
"
,
file
);
this
.
emit
(
'
data
'
,
file
);
});
const
formatting
=
es
.
map
(
function
(
file
,
cb
)
{
tsfmt
.
processString
(
file
.
path
,
file
.
contents
.
toString
(
"
utf8
"
),
{
.
processString
(
file
.
path
,
file
.
contents
.
toString
(
'
utf8
'
),
{
verify
:
false
,
tsfmt
:
true
,
// verbose: true,
...
...
@@ -229,12 +227,12 @@ function hygiene(some) {
})
.
then
(
(
result
)
=>
{
let
original
=
result
.
src
.
replace
(
/
\r\n
/gm
,
"
\n
"
);
let
formatted
=
result
.
dest
.
replace
(
/
\r\n
/gm
,
"
\n
"
);
let
original
=
result
.
src
.
replace
(
/
\r\n
/gm
,
'
\n
'
);
let
formatted
=
result
.
dest
.
replace
(
/
\r\n
/gm
,
'
\n
'
);
if
(
original
!==
formatted
)
{
console
.
error
(
"
File not formatted. Run the 'Format Document' command to fix it:
"
,
`File not formatted. Run the 'Format Document' command to fix it:`
,
file
.
relative
);
errorCount
++
;
...
...
@@ -249,8 +247,8 @@ function hygiene(some) {
let
input
;
if
(
Array
.
isArray
(
some
)
||
typeof
some
===
"
string
"
||
!
some
)
{
const
options
=
{
base
:
"
.
"
,
follow
:
true
,
allowEmpty
:
true
};
if
(
Array
.
isArray
(
some
)
||
typeof
some
===
'
string
'
||
!
some
)
{
const
options
=
{
base
:
'
.
'
,
follow
:
true
,
allowEmpty
:
true
};
if
(
some
)
{
input
=
vfs
.
src
(
some
,
options
).
pipe
(
filter
(
all
));
// split this up to not unnecessarily filter all a second time
}
else
{
...
...
@@ -260,12 +258,12 @@ function hygiene(some) {
input
=
some
;
}
const
productJsonFilter
=
filter
(
"
product.json
"
,
{
restore
:
true
});
const
productJsonFilter
=
filter
(
'
product.json
'
,
{
restore
:
true
});
const
result
=
input
.
pipe
(
filter
((
f
)
=>
!
f
.
stat
.
isDirectory
()))
.
pipe
(
productJsonFilter
)
.
pipe
(
process
.
env
[
"
BUILD_SOURCEVERSION
"
]
?
es
.
through
()
:
productJson
)
.
pipe
(
process
.
env
[
'
BUILD_SOURCEVERSION
'
]
?
es
.
through
()
:
productJson
)
.
pipe
(
productJsonFilter
.
restore
)
.
pipe
(
filter
(
indentationFilter
))
.
pipe
(
indentation
)
...
...
@@ -278,11 +276,11 @@ function hygiene(some) {
.
pipe
(
filter
(
jsHygieneFilter
.
concat
(
tsHygieneFilter
)))
.
pipe
(
gulpeslint
({
configFile
:
"
.eslintrc.json
"
,
rulePaths
:
[
"
./build/lib/eslint
"
],
configFile
:
'
.eslintrc.json
'
,
rulePaths
:
[
'
./build/lib/eslint
'
],
})
)
.
pipe
(
gulpeslint
.
formatEach
(
"
compact
"
))
.
pipe
(
gulpeslint
.
formatEach
(
'
compact
'
))
.
pipe
(
gulpeslint
.
results
((
results
)
=>
{
errorCount
+=
results
.
warningCount
;
...
...
@@ -295,22 +293,22 @@ function hygiene(some) {
es
.
through
(
function
(
data
)
{
count
++
;
if
(
process
.
env
[
"
TRAVIS
"
]
&&
count
%
10
===
0
)
{
process
.
stdout
.
write
(
"
.
"
);
if
(
process
.
env
[
'
TRAVIS
'
]
&&
count
%
10
===
0
)
{
process
.
stdout
.
write
(
'
.
'
);
}
this
.
emit
(
"
data
"
,
data
);
this
.
emit
(
'
data
'
,
data
);
},
function
()
{
process
.
stdout
.
write
(
"
\n
"
);
process
.
stdout
.
write
(
'
\n
'
);
if
(
errorCount
>
0
)
{
this
.
emit
(
"
error
"
,
"
Hygiene failed with
"
+
'
error
'
,
'
Hygiene failed with
'
+
errorCount
+
"
errors. Check 'build/gulpfile.hygiene.js'.
"
` errors. Check 'build / gulpfile.hygiene.js'.`
);
}
else
{
this
.
emit
(
"
end
"
);
this
.
emit
(
'
end
'
);
}
}
)
...
...
@@ -320,7 +318,7 @@ function hygiene(some) {
module
.
exports
.
hygiene
=
hygiene
;
function
createGitIndexVinyls
(
paths
)
{
const
cp
=
require
(
"
child_process
"
);
const
cp
=
require
(
'
child_process
'
);
const
repositoryPath
=
process
.
cwd
();
const
fns
=
paths
.
map
((
relativePath
)
=>
()
=>
...
...
@@ -328,7 +326,7 @@ function createGitIndexVinyls(paths) {
const
fullPath
=
path
.
join
(
repositoryPath
,
relativePath
);
fs
.
stat
(
fullPath
,
(
err
,
stat
)
=>
{
if
(
err
&&
err
.
code
===
"
ENOENT
"
)
{
if
(
err
&&
err
.
code
===
'
ENOENT
'
)
{
// ignore deletions
return
c
(
null
);
}
else
if
(
err
)
{
...
...
@@ -337,7 +335,7 @@ function createGitIndexVinyls(paths) {
cp
.
exec
(
`git show :
${
relativePath
}
`
,
{
maxBuffer
:
2000
*
1024
,
encoding
:
"
buffer
"
},
{
maxBuffer
:
2000
*
1024
,
encoding
:
'
buffer
'
},
(
err
,
out
)
=>
{
if
(
err
)
{
return
e
(
err
);
...
...
@@ -362,22 +360,22 @@ function createGitIndexVinyls(paths) {
// this allows us to run hygiene as a git pre-commit hook
if
(
require
.
main
===
module
)
{
const
cp
=
require
(
"
child_process
"
);
const
cp
=
require
(
'
child_process
'
);
process
.
on
(
"
unhandledRejection
"
,
(
reason
,
p
)
=>
{
console
.
log
(
"
Unhandled Rejection at: Promise
"
,
p
,
"
reason:
"
,
reason
);
process
.
on
(
'
unhandledRejection
'
,
(
reason
,
p
)
=>
{
console
.
log
(
'
Unhandled Rejection at: Promise
'
,
p
,
'
reason:
'
,
reason
);
process
.
exit
(
1
);
});
if
(
process
.
argv
.
length
>
2
)
{
hygiene
(
process
.
argv
.
slice
(
2
)).
on
(
"
error
"
,
(
err
)
=>
{
hygiene
(
process
.
argv
.
slice
(
2
)).
on
(
'
error
'
,
(
err
)
=>
{
console
.
error
();
console
.
error
(
err
);
process
.
exit
(
1
);
});
}
else
{
cp
.
exec
(
"
git diff --cached --name-only
"
,
'
git diff --cached --name-only
'
,
{
maxBuffer
:
2000
*
1024
},
(
err
,
out
)
=>
{
if
(
err
)
{
...
...
@@ -389,15 +387,15 @@ if (require.main === module) {
const
some
=
out
.
split
(
/
\r?\n
/
).
filter
((
l
)
=>
!!
l
);
if
(
some
.
length
>
0
)
{
console
.
log
(
"
Reading git index versions...
"
);
console
.
log
(
'
Reading git index versions...
'
);
createGitIndexVinyls
(
some
)
.
then
(
(
vinyls
)
=>
new
Promise
((
c
,
e
)
=>
hygiene
(
es
.
readArray
(
vinyls
))
.
on
(
"
end
"
,
()
=>
c
())
.
on
(
"
error
"
,
e
)
.
on
(
'
end
'
,
()
=>
c
())
.
on
(
'
error
'
,
e
)
)
)
.
catch
((
err
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录