mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
Stop using node-tmp, use withTmpFile from etcher-sdk instead
Change-type: patch
This commit is contained in:
parent
9114da2445
commit
73f67e99ca
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
|
import { withTmpFile } from 'etcher-sdk/build/tmp';
|
||||||
import { readFile } from 'fs';
|
import { readFile } from 'fs';
|
||||||
import { chain, trim } from 'lodash';
|
import { chain, trim } from 'lodash';
|
||||||
import { platform } from 'os';
|
import { platform } from 'os';
|
||||||
@ -22,8 +23,6 @@ import { join } from 'path';
|
|||||||
import { env } from 'process';
|
import { env } from 'process';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
import { withTmpFile } from '../../../shared/tmp';
|
|
||||||
|
|
||||||
const readFileAsync = promisify(readFile);
|
const readFileAsync = promisify(readFile);
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
@ -41,11 +40,11 @@ async function getWmicNetworkDrivesOutput(): Promise<string> {
|
|||||||
// So we just redirect to a file and read it afterwards as we know it will be ucs2 encoded.
|
// So we just redirect to a file and read it afterwards as we know it will be ucs2 encoded.
|
||||||
const options = {
|
const options = {
|
||||||
// Close the file once it's created
|
// 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 ("-")
|
// Wmic fails with "Invalid global switch" when the "/output:" switch filename contains a dash ("-")
|
||||||
prefix: 'tmp',
|
prefix: 'tmp',
|
||||||
};
|
};
|
||||||
return withTmpFile(options, async (path) => {
|
return withTmpFile(options, async ({ path }) => {
|
||||||
const command = [
|
const command = [
|
||||||
join(env.SystemRoot as string, 'System32', 'Wbem', 'wmic'),
|
join(env.SystemRoot as string, 'System32', 'Wbem', 'wmic'),
|
||||||
'path',
|
'path',
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'child_process';
|
||||||
|
import { withTmpFile } from 'etcher-sdk/build/tmp';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
@ -24,7 +25,6 @@ import { promisify } from 'util';
|
|||||||
|
|
||||||
import { sudo as catalinaSudo } from './catalina-sudo/sudo';
|
import { sudo as catalinaSudo } from './catalina-sudo/sudo';
|
||||||
import * as errors from './errors';
|
import * as errors from './errors';
|
||||||
import { withTmpFile } from './tmp';
|
|
||||||
|
|
||||||
const execAsync = promisify(childProcess.exec);
|
const execAsync = promisify(childProcess.exec);
|
||||||
const execFileAsync = promisify(childProcess.execFile);
|
const execFileAsync = promisify(childProcess.execFile);
|
||||||
@ -172,10 +172,11 @@ export async function elevateCommand(
|
|||||||
);
|
);
|
||||||
return await withTmpFile(
|
return await withTmpFile(
|
||||||
{
|
{
|
||||||
|
keepOpen: false,
|
||||||
prefix: 'balena-etcher-electron-',
|
prefix: 'balena-etcher-electron-',
|
||||||
postfix: '.cmd',
|
postfix: '.cmd',
|
||||||
},
|
},
|
||||||
async (path) => {
|
async ({ path }) => {
|
||||||
await fs.writeFile(path, launchScript);
|
await fs.writeFile(path, launchScript);
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
return elevateScriptWindows(path, options.applicationName);
|
return elevateScriptWindows(path, options.applicationName);
|
||||||
|
20
npm-shrinkwrap.json
generated
20
npm-shrinkwrap.json
generated
@ -12362,26 +12362,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": 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": {
|
"to-buffer": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz",
|
||||||
|
@ -104,7 +104,6 @@
|
|||||||
"styled-components": "^5.1.0",
|
"styled-components": "^5.1.0",
|
||||||
"sudo-prompt": "github:zvin/sudo-prompt#7cdede2f0da28fbcc2db48402d7d935f3a825c91",
|
"sudo-prompt": "github:zvin/sudo-prompt#7cdede2f0da28fbcc2db48402d7d935f3a825c91",
|
||||||
"sys-class-rgb-led": "^3.0.0",
|
"sys-class-rgb-led": "^3.0.0",
|
||||||
"tmp": "^0.2.1",
|
|
||||||
"ts-loader": "^8.0.12",
|
"ts-loader": "^8.0.12",
|
||||||
"ts-node": "^9.0.0",
|
"ts-node": "^9.0.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user