diff --git a/lib/gui/app/os/windows-network-drives.ts b/lib/gui/app/os/windows-network-drives.ts index e84c4c78..bc5df9a6 100755 --- a/lib/gui/app/os/windows-network-drives.ts +++ b/lib/gui/app/os/windows-network-drives.ts @@ -15,6 +15,7 @@ */ import { exec } from 'child_process'; +import { withTmpFile } from 'etcher-sdk/build/tmp'; import { readFile } from 'fs'; import { chain, trim } from 'lodash'; import { platform } from 'os'; @@ -22,8 +23,6 @@ import { join } from 'path'; import { env } from 'process'; import { promisify } from 'util'; -import { withTmpFile } from '../../../shared/tmp'; - const readFileAsync = promisify(readFile); const execAsync = promisify(exec); @@ -41,11 +40,11 @@ async function getWmicNetworkDrivesOutput(): Promise { // So we just redirect to a file and read it afterwards as we know it will be ucs2 encoded. const options = { // Close the file once it's created - discardDescriptor: true, + keepOpen: false, // Wmic fails with "Invalid global switch" when the "/output:" switch filename contains a dash ("-") prefix: 'tmp', }; - return withTmpFile(options, async (path) => { + return withTmpFile(options, async ({ path }) => { const command = [ join(env.SystemRoot as string, 'System32', 'Wbem', 'wmic'), 'path', diff --git a/lib/shared/permissions.ts b/lib/shared/permissions.ts index 94ab1de5..8ae73264 100755 --- a/lib/shared/permissions.ts +++ b/lib/shared/permissions.ts @@ -15,6 +15,7 @@ */ import * as childProcess from 'child_process'; +import { withTmpFile } from 'etcher-sdk/build/tmp'; import { promises as fs } from 'fs'; import * as _ from 'lodash'; import * as os from 'os'; @@ -24,7 +25,6 @@ import { promisify } from 'util'; import { sudo as catalinaSudo } from './catalina-sudo/sudo'; import * as errors from './errors'; -import { withTmpFile } from './tmp'; const execAsync = promisify(childProcess.exec); const execFileAsync = promisify(childProcess.execFile); @@ -172,10 +172,11 @@ export async function elevateCommand( ); return await withTmpFile( { + keepOpen: false, prefix: 'balena-etcher-electron-', postfix: '.cmd', }, - async (path) => { + async ({ path }) => { await fs.writeFile(path, launchScript); if (isWindows) { return elevateScriptWindows(path, options.applicationName); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 68b26aad..d47afada 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -12362,26 +12362,6 @@ "dev": true, "optional": true }, - "tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "dev": true, - "requires": { - "rimraf": "^3.0.0" - }, - "dependencies": { - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } - } - }, "to-buffer": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", diff --git a/package.json b/package.json index 90281f45..fadc4632 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,6 @@ "styled-components": "^5.1.0", "sudo-prompt": "github:zvin/sudo-prompt#7cdede2f0da28fbcc2db48402d7d935f3a825c91", "sys-class-rgb-led": "^3.0.0", - "tmp": "^0.2.1", "ts-loader": "^8.0.12", "ts-node": "^9.0.0", "tslib": "^2.0.0",