patch: Use @balena/sudo-prompt

Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzothunder.ambrosi@gmail.com>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi 2021-11-11 14:39:07 +01:00
parent 685ed715ac
commit 98e33b619b
3 changed files with 15 additions and 12 deletions

View File

@ -20,7 +20,7 @@ import { promises as fs } from 'fs';
import * as _ from 'lodash';
import * as os from 'os';
import * as semver from 'semver';
import * as sudoPrompt from 'sudo-prompt';
import * as sudoPrompt from '@balena/sudo-prompt';
import { promisify } from 'util';
import { sudo as catalinaSudo } from './catalina-sudo/sudo';
@ -29,16 +29,18 @@ import * as errors from './errors';
const execAsync = promisify(childProcess.exec);
const execFileAsync = promisify(childProcess.execFile);
type Std = string | Buffer | undefined;
function sudoExecAsync(
cmd: string,
options: { name: string },
): Promise<{ stdout: string; stderr: string }> {
): Promise<{ stdout: Std; stderr: Std }> {
return new Promise((resolve, reject) => {
sudoPrompt.exec(
cmd,
options,
(error: Error | null, stdout: string, stderr: string) => {
if (error != null) {
(error: Error | undefined, stdout: Std, stderr: Std) => {
if (error !== undefined) {
reject(error);
} else {
resolve({ stdout, stderr });

9
package-lock.json generated
View File

@ -1266,6 +1266,11 @@
"resolved": "https://registry.npmjs.org/@balena/node-crc-utils/-/node-crc-utils-2.0.1.tgz",
"integrity": "sha512-l+PZFPnO0vdx1HNaYq2p89mXIW8XcLoL7XjhwXAAbJ2FOmTg+8fgUEpohX+SJMxTUAE52FBTS8GzIKErCmBNTw=="
},
"@balena/sudo-prompt": {
"version": "9.2.1-workaround-windows-amperstand-in-username-0849e215b947987a643fe5763902aea201255534",
"resolved": "https://registry.npmjs.org/@balena/sudo-prompt/-/sudo-prompt-9.2.1-workaround-windows-amperstand-in-username-0849e215b947987a643fe5763902aea201255534.tgz",
"integrity": "sha512-9s0EDAV4y8KsAc/hQ9rFaE1XlBYbN+/ASiShSowLkJbSUb50B/BqJTfTpUuiEs6d6zhNmPXa8Rn/bPeMW+tn0g=="
},
"@balena/udif": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@balena/udif/-/udif-1.1.2.tgz",
@ -14988,10 +14993,6 @@
"resolved": "https://registry.npmjs.org/stylis/-/stylis-4.0.10.tgz",
"integrity": "sha512-m3k+dk7QeJw660eIKRRn3xPF6uuvHs/FFzjX3HQ5ove0qYsiygoAhwn5a3IYKaZPo5LrYD0rfVmtv1gNY1uYwg=="
},
"sudo-prompt": {
"version": "github:zvin/sudo-prompt#7cdede2f0da28fbcc2db48402d7d935f3a825c91",
"from": "github:zvin/sudo-prompt#7cdede2f0da28fbcc2db48402d7d935f3a825c91"
},
"sumchecker": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz",

View File

@ -16,9 +16,9 @@
"lint-ts": "balena-lint --fix --typescript typings lib tests scripts/clean-shrinkwrap.ts webpack.config.ts",
"lint-css": "prettier --write lib/**/*.css",
"lint": "npm run lint-ts && npm run lint-css",
"test-spectron": "mocha --recursive --reporter spec --require ts-node/register --require-main tests/gui/allow-renderer-process-reuse.ts tests/spectron/runner.spec.ts",
"test-gui": "electron-mocha --recursive --reporter spec --require ts-node/register --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
"test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts",
"test-spectron": "mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts tests/spectron/runner.spec.ts",
"test-gui": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
"test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts",
"test": "npm run lint && npm run test-gui && npm run test-shared && npm run test-spectron && npm run sanity-checks",
"sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh",
"start": "./node_modules/.bin/electron .",
@ -45,6 +45,7 @@
"author": "Balena Inc. <hello@etcher.io>",
"license": "Apache-2.0",
"dependencies": {
"@balena/sudo-prompt": "9.2.1-workaround-windows-amperstand-in-username-0849e215b947987a643fe5763902aea201255534",
"@fortawesome/fontawesome-free": "5.13.1",
"aws4-axios": "2.2.1",
"d3": "4.13.0",
@ -64,7 +65,6 @@
"resin-corvus": "2.0.5",
"semver": "7.3.2",
"styled-components": "5.1.0",
"sudo-prompt": "github:zvin/sudo-prompt#7cdede2f0da28fbcc2db48402d7d935f3a825c91",
"sys-class-rgb-led": "3.0.0",
"url-loader": "4.1.1",
"uuid": "8.1.0"