зеркало из https://github.com/Azure/autorest.git
Fixed race condition in gulp scripts and made them simpler (#2141)
* explanatory * parallel foreach * use threshold
This commit is contained in:
Родитель
e429284556
Коммит
d8326965c1
|
@ -48,7 +48,7 @@
|
|||
"moment": "^2.17.1",
|
||||
"run-sequence": "*",
|
||||
"shelljs": "^0.7.6",
|
||||
"through2": "^2.0.3",
|
||||
"through2-parallel": "^0.1.3",
|
||||
"typescript": "^2.3.0-dev.20170314",
|
||||
"vinyl-paths": "^2.1.0",
|
||||
"vinyl-fs": "^2.4.4",
|
||||
|
|
|
@ -7,8 +7,8 @@ vfs = require('vinyl-fs');
|
|||
|
||||
module.exports =
|
||||
# lets us just handle each item in a stream easily.
|
||||
foreach: (delegate) ->
|
||||
through.obj ( each, enc, done ) ->
|
||||
foreach: (delegate) ->
|
||||
through.obj { concurrency: threshold }, ( each, enc, done ) ->
|
||||
delegate each, done, this
|
||||
|
||||
toArray: (result,passthru) =>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# through = require 'through2'
|
||||
|
||||
# tools
|
||||
csu = "c:/ci-signing/adxsdk/tools/csu/csu.exe"
|
||||
|
||||
dotnet = (cmd) ->
|
||||
through.obj (file, enc, callback) ->
|
||||
foreach (file, callback) ->
|
||||
# check if the file is an actual file.
|
||||
# if it's not, just skip this tool.
|
||||
if !file or !file.path
|
||||
|
@ -19,7 +17,6 @@ dotnet = (cmd) ->
|
|||
###############################################
|
||||
# Common Tasks
|
||||
|
||||
|
||||
###############################################
|
||||
task 'reset-dotnet-cache', 'removes installed dotnet-packages so restore is clean', ->
|
||||
rm '-rf', "#{os.homedir()}/.nuget"
|
||||
|
@ -88,43 +85,24 @@ task 'sign-assemblies','', (done) ->
|
|||
task 'restore','restores the dotnet packages for the projects', (done) ->
|
||||
if ! test '-d', "#{os.homedir()}/.nuget"
|
||||
global.force = true
|
||||
instances = 0
|
||||
_done = () ->
|
||||
if instances is 0
|
||||
instances--
|
||||
done();
|
||||
|
||||
projects()
|
||||
.on 'end', ->
|
||||
_done()
|
||||
.pipe where (each) -> # check for project.assets.json files are up to date
|
||||
return true if force
|
||||
assets = "#{folder each.path}/obj/project.assets.json"
|
||||
return false if (exists assets) and (newer assets, each.path)
|
||||
return true
|
||||
.pipe foreach (each,next)->
|
||||
any = true
|
||||
instances++
|
||||
execute "dotnet restore #{ each.path } /nologo",{retry:1} ,(code,stderr,stdout) ->
|
||||
instances--
|
||||
_done()
|
||||
next null
|
||||
return null
|
||||
.pipe foreach (each,done)->
|
||||
execute "dotnet restore #{ each.path } /nologo", {retry:1},(code,stderr,stdout) ->
|
||||
done()
|
||||
|
||||
###############################################
|
||||
task 'test-dotnet', 'runs dotnet tests',['restore'] , (done) ->
|
||||
instances = 0
|
||||
|
||||
# run xunit test in parallel with each other.
|
||||
tests()
|
||||
.pipe foreach (each,next)->
|
||||
instances++
|
||||
.pipe foreach (each,done)->
|
||||
execute "dotnet test #{ each.path } /nologo",{retry:1}, (code,stderr,stdout) ->
|
||||
instances--
|
||||
done() if instances is 0
|
||||
next null
|
||||
return null
|
||||
|
||||
done()
|
||||
|
||||
global['codesign'] = (description, keywords, input, output, certificate1, certificate2, done)->
|
||||
done = if done? then done else if certificate2? then certificate2 else if certificate1? then certificate1 else ()->
|
||||
|
|
|
@ -33,7 +33,7 @@ Install 'chalk'
|
|||
Install 'yargs'
|
||||
Install 'ghrelease', 'gulp-github-release'
|
||||
Install 'eol', 'gulp-line-ending-corrector'
|
||||
Install 'through', 'through2'
|
||||
Install 'through', 'through2-parallel'
|
||||
Install 'run', 'run-sequence'
|
||||
Install 'except', './except.iced'
|
||||
|
||||
|
|
|
@ -5,11 +5,10 @@
|
|||
|
||||
regenExpected = (opts,done) ->
|
||||
outputDir = if !!opts.outputBaseDir then "#{opts.outputBaseDir}/#{opts.outputDir}" else opts.outputDir
|
||||
instances = 0
|
||||
|
||||
for key of opts.mappings
|
||||
instances++
|
||||
keys = Object.getOwnPropertyNames(opts.mappings)
|
||||
instances = keys.length
|
||||
|
||||
for key in keys
|
||||
optsMappingsValue = opts.mappings[key]
|
||||
swaggerFiles = (if optsMappingsValue instanceof Array then optsMappingsValue[0] else optsMappingsValue).split(";")
|
||||
args = [
|
||||
|
@ -51,7 +50,7 @@ regenExpected = (opts,done) ->
|
|||
args.push("--override-info.description=#{opts['override-info.description']}")
|
||||
|
||||
autorest args,() =>
|
||||
instances = instances- 1
|
||||
instances--
|
||||
return done() if instances is 0
|
||||
|
||||
defaultMappings = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче