diff --git a/package.json b/package.json index afa93f0..e772b08 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "0.7.6", + "version": "0.7.7", "description": "Download a specific release from github", "main": "lib/index.js", "typings": "index.d.ts", diff --git a/src/downloadRelease.js b/src/downloadRelease.js index e560ef6..2ec8a74 100644 --- a/src/downloadRelease.js +++ b/src/downloadRelease.js @@ -16,7 +16,7 @@ const MultiProgress = require('multi-progress'); async function downloadRelease( user, repo, - outputDir, + _outputDir, filterRelease = pass, filterAsset = pass, leaveZipped = false, @@ -47,6 +47,15 @@ async function downloadRelease( progress = bar.update.bind(bar); } + const outputDir = path.isAbsolute(_outputDir) ? _outputDir : path.resolve(_outputDir); + if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir); + } + + if (!fs.statSync(outputDir).isDirectory()) { + throw new Error(`Output path "${outputDir}" must be a directory`); + } + const destf = path.join(outputDir, asset.name); if (!fs.existsSync(destf)) { const dest = fs.createWriteStream(destf);