mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-15 06:56:34 +00:00
Use the promises namespace of balena-image-fs
Change-type: patch
This commit is contained in:
parent
1d77cf3665
commit
29e7827eb1
@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { Args, Command } from '@oclif/core';
|
||||
import { promisify } from 'util';
|
||||
import { stripIndent } from '../../utils/lazy';
|
||||
|
||||
export default class LocalConfigureCmd extends Command {
|
||||
@ -237,7 +236,7 @@ export default class LocalConfigureCmd extends Command {
|
||||
const bootPartition = await getBootPartition(target);
|
||||
|
||||
const files = await imagefs.interact(target, bootPartition, async (_fs) => {
|
||||
return await promisify(_fs.readdir)(this.CONNECTIONS_FOLDER);
|
||||
return await _fs.promises.readdir(this.CONNECTIONS_FOLDER);
|
||||
});
|
||||
|
||||
let connectionFileName;
|
||||
@ -246,13 +245,14 @@ export default class LocalConfigureCmd extends Command {
|
||||
} else if (_.includes(files, 'resin-sample.ignore')) {
|
||||
// Fresh image, new mode, accoding to https://github.com/balena-os/meta-balena/pull/770/files
|
||||
await imagefs.interact(target, bootPartition, async (_fs) => {
|
||||
const readFileAsync = promisify(_fs.readFile);
|
||||
const writeFileAsync = promisify(_fs.writeFile);
|
||||
const contents = await readFileAsync(
|
||||
const contents = await _fs.promises.readFile(
|
||||
`${this.CONNECTIONS_FOLDER}/resin-sample.ignore`,
|
||||
{ encoding: 'utf8' },
|
||||
);
|
||||
await writeFileAsync(`${this.CONNECTIONS_FOLDER}/resin-wifi`, contents);
|
||||
await _fs.promises.writeFile(
|
||||
`${this.CONNECTIONS_FOLDER}/resin-wifi`,
|
||||
contents,
|
||||
);
|
||||
});
|
||||
} else if (_.includes(files, 'resin-sample')) {
|
||||
// Legacy mode, to be removed later
|
||||
@ -266,7 +266,7 @@ export default class LocalConfigureCmd extends Command {
|
||||
} else {
|
||||
// In case there's no file at all (shouldn't happen normally, but the file might have been removed)
|
||||
await imagefs.interact(target, bootPartition, async (_fs) => {
|
||||
await promisify(_fs.writeFile)(
|
||||
await _fs.promises.writeFile(
|
||||
`${this.CONNECTIONS_FOLDER}/resin-wifi`,
|
||||
this.CONNECTION_FILE,
|
||||
);
|
||||
|
@ -18,7 +18,6 @@
|
||||
import { Flags, Args, Command } from '@oclif/core';
|
||||
import type { Interfaces } from '@oclif/core';
|
||||
import type * as BalenaSdk from 'balena-sdk';
|
||||
import { promisify } from 'util';
|
||||
import * as _ from 'lodash';
|
||||
import { ExpectedError } from '../../errors';
|
||||
import * as cf from '../../utils/common-flags';
|
||||
@ -292,7 +291,7 @@ export default class OsConfigureCmd extends Command {
|
||||
|
||||
for (const { name, content } of files) {
|
||||
await imagefs.interact(image, bootPartition, async (_fs) => {
|
||||
await promisify(_fs.writeFile)(
|
||||
await _fs.promises.writeFile(
|
||||
path.join(CONNECTIONS_FOLDER, name),
|
||||
content,
|
||||
);
|
||||
|
@ -62,20 +62,22 @@ if (process.platform !== 'win32') {
|
||||
tmpNonMatchingDtJsonPartitionPath,
|
||||
12,
|
||||
async (_fs) => {
|
||||
const readFileAsync = promisify(_fs.readFile);
|
||||
const writeFileAsync = promisify(_fs.writeFile);
|
||||
|
||||
const dtJson = JSON.parse(
|
||||
await readFileAsync('/device-type.json', { encoding: 'utf8' }),
|
||||
await _fs.promises.readFile('/device-type.json', {
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
);
|
||||
expect(dtJson).to.have.nested.property(
|
||||
'configuration.config.partition',
|
||||
12,
|
||||
);
|
||||
dtJson.configuration.config.partition = 999;
|
||||
await writeFileAsync('/device-type.json', JSON.stringify(dtJson));
|
||||
await _fs.promises.writeFile(
|
||||
'/device-type.json',
|
||||
JSON.stringify(dtJson),
|
||||
);
|
||||
|
||||
await writeFileAsync(
|
||||
await _fs.promises.writeFile(
|
||||
'/os-release',
|
||||
stripIndent`
|
||||
ID="balena-os"
|
||||
@ -133,16 +135,17 @@ if (process.platform !== 'win32') {
|
||||
tmpMatchingDtJsonPartitionPath,
|
||||
12,
|
||||
async (_fs) => {
|
||||
const readFileAsync = promisify(_fs.readFile);
|
||||
const dtJson = JSON.parse(
|
||||
await readFileAsync('/device-type.json', { encoding: 'utf8' }),
|
||||
await _fs.promises.readFile('/device-type.json', {
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
);
|
||||
// confirm that the device-type.json mentions the expected partition
|
||||
expect(dtJson).to.have.nested.property(
|
||||
'configuration.config.partition',
|
||||
12,
|
||||
);
|
||||
return await readFileAsync('/config.json');
|
||||
return await _fs.promises.readFile('/config.json');
|
||||
},
|
||||
);
|
||||
expect(config).to.not.be.empty;
|
||||
@ -180,16 +183,17 @@ if (process.platform !== 'win32') {
|
||||
tmpNonMatchingDtJsonPartitionPath,
|
||||
12,
|
||||
async (_fs) => {
|
||||
const readFileAsync = promisify(_fs.readFile);
|
||||
const dtJson = JSON.parse(
|
||||
await readFileAsync('/device-type.json', { encoding: 'utf8' }),
|
||||
await _fs.promises.readFile('/device-type.json', {
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
);
|
||||
// confirm that the device-type.json mentions the expected partition
|
||||
expect(dtJson).to.have.nested.property(
|
||||
'configuration.config.partition',
|
||||
999,
|
||||
);
|
||||
return await readFileAsync('/config.json');
|
||||
return await _fs.promises.readFile('/config.json');
|
||||
},
|
||||
);
|
||||
expect(config).to.not.be.empty;
|
||||
@ -240,7 +244,7 @@ if (process.platform !== 'win32') {
|
||||
|
||||
// confirm the image contains a config.json...
|
||||
const config = await imagefs.interact(tmpDummyPath, 1, async (_fs) => {
|
||||
return await promisify(_fs.readFile)('/config.json');
|
||||
return await _fs.promises.readFile('/config.json');
|
||||
});
|
||||
expect(config).to.not.be.empty;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user