better sorter function
This commit is contained in:
parent
a965cf38c8
commit
19e3aa3721
45
dist/npmci.build.docker.js
vendored
45
dist/npmci.build.docker.js
vendored
File diff suppressed because one or more lines are too long
@ -27,25 +27,38 @@ let readDockerfiles = function(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cleanTagsArrayFunction = function(){
|
||||||
|
let cleanTagsArray = [];
|
||||||
|
NpmciEnv.dockerFiles.forEach(function(dockerfileArg){
|
||||||
|
cleanTagsArray.push(dockerfileArg.cleanTag);
|
||||||
|
});
|
||||||
|
return cleanTagsArray;
|
||||||
|
}
|
||||||
|
|
||||||
let sortDockerfiles = function(){
|
let sortDockerfiles = function(){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
NpmciEnv.dockerFiles.sort(function(a,b){
|
let sortableArray = NpmciEnv.dockerFiles;
|
||||||
let cleanTags = [];
|
let sortedArray:Dockerfile[] = [];
|
||||||
NpmciEnv.dockerFiles.forEach(function(dockerfileArg){
|
let sorterFunctionCounter:number = 0;
|
||||||
cleanTags.push(dockerfileArg.cleanTag);
|
let sorterFunction = function(){
|
||||||
});
|
let cleanTags = cleanTagsArrayFunction();
|
||||||
let aIndex = cleanTags.indexOf(a.baseImage);
|
sortableArray.forEach((dockerfileArg)=>{
|
||||||
let bIndex = cleanTags.indexOf(b.cleanTag);
|
if(cleanTags.indexOf(dockerfileArg.baseImage) == -1){
|
||||||
console.log(cleanTags);
|
let dockerfileArgIndex = sortableArray.indexOf(dockerfileArg);
|
||||||
console.log(a.baseImage,aIndex);
|
sortableArray.splice(dockerfileArgIndex);
|
||||||
console.log(b.cleanTag,bIndex);
|
sortedArray.push(dockerfileArg);
|
||||||
if(aIndex < bIndex && bIndex != -1){
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if(sortableArray.length == 0){
|
||||||
|
console.log(sortedArray);
|
||||||
|
NpmciEnv.dockerFiles = sortedArray;
|
||||||
done.resolve();
|
done.resolve();
|
||||||
|
} else if (sorterFunctionCounter < 100) {
|
||||||
|
sorterFunctionCounter++;
|
||||||
|
sorterFunction();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
sorterFunction();
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user