specify-artifact
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -124,3 +124,3 @@ 'use strict' | ||
function(done) { | ||
if (_.startsWith(input, 'dockerhub:')) return done(); | ||
if (spec.dockerhub) return done(); | ||
@@ -185,4 +185,2 @@ prepare(input, options, (err, output) => { | ||
delete args.type; | ||
const source_repository_url = args.source_repository_url || args.spec.source_repository_url; | ||
@@ -192,2 +190,4 @@ | ||
delete args.type; | ||
prepare(source_repository_url, args, (err, output) => { | ||
@@ -194,0 +194,0 @@ if (err) return done(err); |
@@ -68,5 +68,6 @@ 'use strict' | ||
let output; | ||
let outputPath; | ||
let outputType; | ||
let outputCreated = false; | ||
let cleanupPaths = options.cleanupPaths || []; | ||
let cleanupExcludes = options.cleanupExcludes || []; | ||
@@ -106,10 +107,15 @@ const downloadDir = path.join(os.tmpdir(), 'specify-artifact', 'download-' + shortid.generate()); | ||
if (inputType === 'dir') { | ||
output = input; | ||
outputPath = input; | ||
done(); | ||
} else { | ||
output = path.join(os.tmpdir(), 'specify-artifact', shortid.generate()); | ||
outputCreated = true; | ||
outputPath = path.join(os.tmpdir(), 'specify-artifact', shortid.generate()); | ||
fs.ensureDir(output, done); | ||
fs.ensureDir(outputPath, (err) => { | ||
if (err) return done(err); | ||
cleanupPaths.push(outputPath); | ||
done(); | ||
}); | ||
} | ||
@@ -122,19 +128,13 @@ }, | ||
args.url = input; | ||
args.dir = output; | ||
args.dir = outputPath; | ||
checkoutGit(args, done); | ||
} else if (inputType === 'file') { | ||
decompress(input, output, options).then(files => { | ||
const tempOutput = output; | ||
const tempOutputCreated = outputCreated; | ||
decompress(input, outputPath, options).then(files => { | ||
if (_.isEmpty(files)) { | ||
output = input; | ||
outputPath = input; | ||
outputType = 'file'; | ||
outputCreated = false; | ||
} | ||
if (tempOutputCreated) fs.remove(tempOutput, done); | ||
} else { | ||
done(); | ||
} | ||
done(); | ||
}).catch(done); | ||
@@ -147,12 +147,10 @@ } else if (inputType === 'http') { | ||
decompress(path.join(downloadDir, downloadFilename), output, options).then(files => { | ||
const tempOutput = output; | ||
const tempOutputCreated = outputCreated; | ||
decompress(path.join(downloadDir, downloadFilename), outputPath, options).then(files => { | ||
if (_.isEmpty(files)) { | ||
output = path.join(downloadDir, downloadFilename); | ||
outputPath = path.join(downloadDir, downloadFilename); | ||
outputType = 'file'; | ||
outputCreated = true; | ||
if (tempOutputCreated) fs.remove(tempOutput, done); | ||
cleanupPaths.push(downloadDir); | ||
done(); | ||
} else { | ||
@@ -180,18 +178,17 @@ fs.remove(downloadDir, done); | ||
const currentOutput = output; | ||
const currentOutputPath = outputPath; | ||
const outputBase = path.join(os.tmpdir(), 'specify-artifact', shortid.generate()); | ||
output = path.join(os.tmpdir(), 'specify-artifact', shortid.generate(), shortid.generate()); | ||
outputPath = path.join(outputBase, path.basename(options.subpath)); | ||
fs.ensureDir(path.dirname(output), (err) => { | ||
fs.ensureDir(path.dirname(outputPath), (err) => { | ||
if (err) return done(err); | ||
fs.move(path.join(currentOutput, options.subpath), output, { clobber: true }, (err) => { | ||
if (err) return done(err); | ||
cleanupPaths.push(outputBase); | ||
fs.remove(currentOutput, done); | ||
}); | ||
fs.move(path.join(currentOutputPath, options.subpath), outputPath, { clobber: true }, done); | ||
}); | ||
}, | ||
function(done) { | ||
fs.stat(output, (err, stats) => { | ||
fs.stat(outputPath, (err, stats) => { | ||
if (err) return done(err); | ||
@@ -206,9 +203,20 @@ | ||
], function(err) { | ||
//TODO add files array to returned object | ||
//TODO add files array to returned object? | ||
cleanupPaths = _.uniq(cleanupPaths); | ||
cleanupExcludes = _.uniq(cleanupExcludes); | ||
done(err, { | ||
path: output, | ||
path: outputPath, | ||
type: outputType, | ||
created: outputCreated | ||
cleanupPaths: cleanupPaths, | ||
cleanupExcludes: cleanupExcludes, | ||
cleanup: (done) => { | ||
async.eachSeries(cleanupPaths, function(p, done) { | ||
if (_.includes(cleanupExcludes, p)) return done(); | ||
else fs.remove(p, done); | ||
}, done); | ||
} | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "specify-artifact", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Analyze an artifact to specify its properties such as config parameters etc.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,2 @@ 'use strict' | ||
const async = require('async'); | ||
const fs = require('fs-extra'); | ||
@@ -25,3 +24,3 @@ const chef = require('../lib/chef'); | ||
fs.remove(result.path, done); | ||
result.cleanup(done); | ||
}); | ||
@@ -42,3 +41,3 @@ }); | ||
fs.remove(result.path, done); | ||
result.cleanup(done); | ||
}); | ||
@@ -45,0 +44,0 @@ }); |
@@ -5,3 +5,2 @@ 'use strict' | ||
const async = require('async'); | ||
const fs = require('fs-extra'); | ||
@@ -24,3 +23,3 @@ const docker = require('../lib/docker'); | ||
fs.remove(result.path, done); | ||
result.cleanup(done); | ||
}); | ||
@@ -40,3 +39,3 @@ }); | ||
fs.remove(result.path, done); | ||
result.cleanup(done); | ||
}); | ||
@@ -56,3 +55,3 @@ }); | ||
fs.remove(result.path, done); | ||
result.cleanup(done); | ||
}); | ||
@@ -59,0 +58,0 @@ }); |
@@ -5,3 +5,2 @@ 'use strict' | ||
const async = require('async'); | ||
const fs = require('fs-extra'); | ||
@@ -19,3 +18,3 @@ const prepare = require('../lib/prepare'); | ||
fs.remove(output.path, done); | ||
output.cleanup(done); | ||
}); | ||
@@ -29,3 +28,3 @@ }, | ||
done(); | ||
output.cleanup(done); | ||
}); | ||
@@ -39,3 +38,3 @@ }, | ||
fs.remove(output.path, done); | ||
output.cleanup(done); | ||
}); | ||
@@ -49,3 +48,3 @@ }, | ||
done(); | ||
output.cleanup(done); | ||
}); | ||
@@ -59,3 +58,3 @@ }, | ||
fs.remove(output.path, done); | ||
output.cleanup(done); | ||
}); | ||
@@ -69,3 +68,3 @@ }, | ||
fs.remove(output.path, done); | ||
output.cleanup(done); | ||
}); | ||
@@ -72,0 +71,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40688
698
6