diff --git a/package-lock.json b/package-lock.json index 3d17010..29d3cdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@super-protocol/ctl", - "version": "0.14.4", + "version": "0.14.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@super-protocol/ctl", - "version": "0.14.4", + "version": "0.14.6", "license": "MIT", "dependencies": { "@amplitude/node": "^1.10.2", diff --git a/package.json b/package.json index cb3e6f8..36314c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@super-protocol/ctl", - "version": "0.14.4", + "version": "0.14.6", "description": "A tool for publishing values in a secure and reliable way.", "main": "./build/index.js", "type": "commonjs", diff --git a/src/commands/filesDownload.addon.ts b/src/commands/filesDownload.addon.ts index a611487..ae72f77 100644 --- a/src/commands/filesDownload.addon.ts +++ b/src/commands/filesDownload.addon.ts @@ -1,4 +1,4 @@ -import { promises as fs } from 'fs'; +import path from 'path'; import Printer from '../printer'; import { isCommandSupported } from '../services/uplinkSetupHelper'; import readResourceFileService from '../services/readResourceFile'; @@ -23,15 +23,12 @@ export default async (params: FilesDownloadParams): Promise => { `Resource type ${resource.type} is not supported, use StorageProvider type for this command`, ); - const localPath = preparePath(params.localDirectory).replace(/\/$/, ''); - const exists = await fs.stat(localPath).catch(() => null); - - if (!exists) { - await fs.mkdir(localPath, { recursive: true }); - } else if (!exists.isDirectory()) { - throw new Error('localDirectory argument must be the path to a folder'); + let localPath = preparePath(params.localDirectory).replace(/\/$/, ''); + if (resource.filepath) { + localPath = path.join(localPath, resource.filepath); } + Printer.print(`Downloading file to ${localPath}`); try { const { download } = await import('@super-protocol/sp-files-addon'); await download(resource, localPath, {