Skip to content

Commit

Permalink
fix: single file upload on Node 16 (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhagmajer authored Dec 15, 2022
1 parent 83ac6d7 commit d94ab35
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 89 deletions.
165 changes: 103 additions & 62 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
"date-fns": "^1.29.0",
"debug": "^4.1.0",
"express": "^4.17.1",
"fs-extra": "^7.0.0",
"fs-extra": "^10.1.0",
"inquirer": "^6.2.0",
"js-yaml": "^3.13.1",
"keychain": "^1.3.0",
"keytar": "^7.9.0",
"lodash": "^4.17.13",
"mkdirp": "^1.0.4",
"nanoid": "^3.3.1",
"open": "^8.0.4",
"ora": "^5.4.1",
Expand Down
11 changes: 6 additions & 5 deletions src/box-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const { Command, flags } = require('@oclif/command');
const chalk = require('chalk');
const util = require('util');
const _ = require('lodash');
const fs = require('fs-extra');
const fs = require('fs');
const mkdirp = require('mkdirp');
const os = require('os');
const path = require('path');
const yaml = require('js-yaml');
Expand Down Expand Up @@ -915,7 +916,7 @@ class BoxCommand extends Command {
stringifiedOutput = await this._stringifyOutput(formattedOutputData);

writeFunc = async(savePath) => {
await fs.writeFile(savePath, stringifiedOutput + os.EOL, {
await utils.writeFileAsync(savePath, stringifiedOutput + os.EOL, {
encoding: 'utf8',
});
};
Expand Down Expand Up @@ -1495,7 +1496,7 @@ class BoxCommand extends Command {
async _loadSettings() {
try {
if (!fs.existsSync(CONFIG_FOLDER_PATH)) {
fs.mkdirpSync(CONFIG_FOLDER_PATH);
mkdirp.sync(CONFIG_FOLDER_PATH);
DEBUG.init('Created config folder at %s', CONFIG_FOLDER_PATH);
}
if (!fs.existsSync(ENVIRONMENTS_FILE_PATH)) {
Expand Down Expand Up @@ -1529,14 +1530,14 @@ class BoxCommand extends Command {

try {
if (!fs.existsSync(settings.boxReportsFolderPath)) {
fs.mkdirpSync(settings.boxReportsFolderPath);
mkdirp.sync(settings.boxReportsFolderPath);
DEBUG.init(
'Created reports folder at %s',
settings.boxReportsFolderPath
);
}
if (!fs.existsSync(settings.boxDownloadsFolderPath)) {
fs.mkdirpSync(settings.boxDownloadsFolderPath);
mkdirp.sync(settings.boxDownloadsFolderPath);
DEBUG.init(
'Created downloads folder at %s',
settings.boxDownloadsFolderPath
Expand Down
7 changes: 4 additions & 3 deletions src/commands/configure/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

const BoxCommand = require('../../box-command');
const { flags } = require('@oclif/command');
const fs = require('fs-extra');
const fs = require('fs');
const mkdirp = require('mkdirp');
const BoxCLIError = require('../../cli-error');
const utils = require('../../util');

Expand All @@ -27,7 +28,7 @@ class ConfigureSettingsCommand extends BoxCommand {
}

try {
await fs.mkdirp(downloadsPath);
await mkdirp(downloadsPath);
} catch (ex) {
throw new BoxCLIError('Could not create downloads directory', ex);
}
Expand All @@ -54,7 +55,7 @@ class ConfigureSettingsCommand extends BoxCommand {
}

try {
await fs.mkdirp(reportsPath);
await mkdirp(reportsPath);
} catch (ex) {
throw new BoxCLIError('Could not create downloads directory', ex);
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/files/upload.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable no-sync */
'use strict';

const BoxCommand = require('../../box-command');
const { flags } = require('@oclif/command');
const fs = require('fs-extra');
const fs = require('fs');
const path = require('path');
const progress = require('cli-progress');
const BoxCLIError = require('../../cli-error');
Expand All @@ -12,7 +13,7 @@ const CHUNKED_UPLOAD_FILE_SIZE = 1024 * 1024 * 100; // 100 MiB
class FilesUploadCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(FilesUploadCommand);
let size = (await fs.stat(args.path)).size;
let size = fs.statSync(args.path).size;
let folderID = flags['parent-id'];
let stream;
try {
Expand Down
Loading

0 comments on commit d94ab35

Please sign in to comment.