osConfigure/localFlash: Add support for Node.js v14

* Replace old resin-image-fs with newer balena-image-fs
* package.json: Remove resin-image-fs package
* package: Install dependencies that work with node14
* Remove resin-image-fs typings
* Fix etcher-sdk related types
* local/flash: Add unmountOnSuccess, write, direct properties on flash
	Taken from https://github.com/balena-io-modules/etcher-sdk/blob/master/examples/multi-destination.ts
* tests/utils/eol-conversion: Remove ext2fs sample binary
	Specifically ext2fs/build/Release/bindings.node
	I removed it because the file doesn't exist
* tests/test-data/pkg: Add new expected warnings darwin/linux/windows
* os/configure: Remove windows check
* local/flash: Check if environment is WSL and show warning message
* Get tests to pass with certain Node v14 warning messages
* INSTALL-WINDOWS: Remove os configure warning

Improve push and logs support for Node.js v14 (bump 'net-keepalive')

Resolves: #2200
Resolves: #1990
Change-type: minor
Signed-off-by: Marios Balamatsias <mbalamatsias@gmail.com>
This commit is contained in:
Marios Balamatsias 2021-01-21 21:27:07 +02:00
parent 2737c9c53c
commit ac96616e4e
15 changed files with 1685 additions and 439 deletions

View File

@ -79,10 +79,3 @@ because the AUFS storage driver is not present in the Linux kernel used by the n
of Docker Desktop for Windows or macOS.
We are working on replacing AUFS with overlay2 in balenaOS images of the affected device types.
### balena os configure
* The `balena os configure` command is currently not supported on Windows natively, but works with
the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about) (WSL). When
using WSL, [install the balena CLI for
Linux](https://github.com/balena-io/balena-cli/blob/master/INSTALL-LINUX.md).

View File

@ -21,6 +21,22 @@ import * as path from 'path';
export const ROOT = path.join(__dirname, '..');
const nodeEngineWarn = `\
------------------------------------------------------------------------------
Warning: Node version "v14.x.x" does not match required versions ">=10.20.0 <13.0.0".
This may cause unexpected behavior. To upgrade Node, visit:
https://nodejs.org/en/download/
------------------------------------------------------------------------------
`;
const nodeEngineWarnArray = nodeEngineWarn.split('\n').filter((l) => l);
export function matchesNodeEngineVersionWarn(line: string) {
line = line.replace(/"v14\.\d{1,3}\.\d{1,3}"/, '"v14.x.x"');
return (
line === nodeEngineWarn || nodeEngineWarnArray.includes(line.trimEnd())
);
}
/** Tap and buffer this process' stdout and stderr */
export class StdOutTap {
public stdoutBuf: string[] = [];
@ -120,7 +136,8 @@ export async function getSubprocessStdout(
// every line provided to the stderr stream
const lines = _.filter(
stderr.trim().split(/\r?\n/),
(line) => !line.startsWith('[debug]'),
(line) =>
!line.startsWith('[debug]') && !matchesNodeEngineVersionWarn(line),
);
if (lines.length > 0) {
reject(

View File

@ -16,6 +16,7 @@
*/
import { flags } from '@oclif/command';
import { promisify } from 'util';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { stripIndent } from '../../utils/lazy';
@ -59,7 +60,6 @@ export default class LocalConfigureCmd extends Command {
public async run() {
const { args: params } = this.parse<FlagsDef, ArgsDef>(LocalConfigureCmd);
const { promisify } = await import('util');
const path = await import('path');
const umount = await import('umount');
const umountAsync = promisify(umount.umount);
@ -253,31 +253,27 @@ export default class LocalConfigureCmd extends Command {
*/
async prepareConnectionFile(target: string) {
const _ = await import('lodash');
const imagefs = await import('resin-image-fs');
const imagefs = await import('balena-image-fs');
const files = await imagefs.listDirectory({
image: target,
partition: this.BOOT_PARTITION,
path: this.CONNECTIONS_FOLDER,
});
const files = await imagefs.interact(
target,
this.BOOT_PARTITION,
async (_fs) => {
return await promisify(_fs.readdir)(this.CONNECTIONS_FOLDER);
},
);
let connectionFileName;
if (_.includes(files, 'resin-wifi')) {
// The required file already exists, nothing to do
} 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.copy(
{
image: target,
partition: this.BOOT_PARTITION,
path: `${this.CONNECTIONS_FOLDER}/resin-sample.ignore`,
},
{
image: target,
partition: this.BOOT_PARTITION,
path: `${this.CONNECTIONS_FOLDER}/resin-wifi`,
},
);
await imagefs.interact(target, this.BOOT_PARTITION, async (_fs) => {
return await promisify(_fs.copyFile)(
`${this.CONNECTIONS_FOLDER}/resin-sample.ignore`,
`${this.CONNECTIONS_FOLDER}/resin-wifi`,
);
});
} else if (_.includes(files, 'resin-sample')) {
// Legacy mode, to be removed later
// We return the file name override from this branch
@ -289,14 +285,12 @@ export default class LocalConfigureCmd extends Command {
connectionFileName = 'resin-sample';
} else {
// In case there's no file at all (shouldn't happen normally, but the file might have been removed)
await imagefs.writeFile(
{
image: target,
partition: this.BOOT_PARTITION,
path: `${this.CONNECTIONS_FOLDER}/resin-wifi`,
},
this.CONNECTION_FILE,
);
await imagefs.interact(target, this.BOOT_PARTITION, async (_fs) => {
return await promisify(_fs.writeFile)(
`${this.CONNECTIONS_FOLDER}/resin-wifi`,
this.CONNECTION_FILE,
);
});
}
return await this.getConfigurationSchema(connectionFileName);
}

View File

@ -16,6 +16,7 @@
*/
import { flags } from '@oclif/command';
import type { BlockDevice } from 'etcher-sdk/build/source-destination';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
@ -25,7 +26,6 @@ import {
getVisuals,
stripIndent,
} from '../../utils/lazy';
import type * as SDK from 'etcher-sdk';
interface FlagsDef {
yes: boolean;
@ -75,6 +75,23 @@ export default class LocalFlashCmd extends Command {
LocalFlashCmd,
);
if (process.platform === 'linux') {
const { promisify } = await import('util');
const { exec } = await import('child_process');
const execAsync = promisify(exec);
let distroVersion = '';
try {
const info = await execAsync('cat /proc/version');
distroVersion = info.stdout.toLowerCase();
// tslint:disable-next-line: no-empty
} catch {}
if (distroVersion.includes('microsoft')) {
throw new ExpectedError(stripIndent`
This command is known not to work on WSL. Please use a CLI release
for Windows (not WSL), or balenaEtcher.`);
}
}
const { sourceDestination, multiWrite } = await import('etcher-sdk');
const drive = await this.getDrive(options);
@ -93,10 +110,9 @@ export default class LocalFlashCmd extends Command {
process.exit(0);
}
const file = new sourceDestination.File(
params.image,
sourceDestination.File.OpenFlags.Read,
);
const file = new sourceDestination.File({
path: params.image,
});
const source = await file.getInnerSource();
const visuals = getVisuals();
@ -105,29 +121,37 @@ export default class LocalFlashCmd extends Command {
verifying: new visuals.Progress('Validating'),
};
await multiWrite.pipeSourceToDestinations(
await multiWrite.pipeSourceToDestinations({
source,
[drive],
(_, error) => {
// onFail
console.log(getChalk().red.bold(error.message));
destinations: [drive],
onFail: (_, error) => {
console.error(getChalk().red.bold(error.message));
if (error.message.includes('EACCES')) {
console.error(
getChalk().red.bold(
'Try running this command with elevated privileges, with sudo or in a shell running with admininstrator privileges.',
),
);
}
},
(progress: SDK.multiWrite.MultiDestinationProgress) => {
// onProgress
onProgress: (progress) => {
progressBars[progress.type].update(progress);
},
true, // verify
);
verify: true,
});
}
async getDrive(options: {
drive?: string;
}): Promise<SDK.sourceDestination.BlockDevice> {
async getDrive(options: { drive?: string }): Promise<BlockDevice> {
const drive = options.drive || (await getVisuals().drive('Select a drive'));
const sdk = await import('etcher-sdk');
const adapter = new sdk.scanner.adapters.BlockDeviceAdapter(() => false);
const adapter = new sdk.scanner.adapters.BlockDeviceAdapter({
includeSystemDrives: () => false,
unmountOnSuccess: false,
write: true,
direct: true,
});
const scanner = new sdk.scanner.Scanner([adapter]);
await scanner.start();
try {

View File

@ -17,6 +17,7 @@
import { flags } from '@oclif/command';
import type * as BalenaSdk from 'balena-sdk';
import { promisify } from 'util';
import * as _ from 'lodash';
import Command from '../../command';
import { ExpectedError } from '../../errors';
@ -279,17 +280,16 @@ export default class OsConfigureCmd extends Command {
};
}),
);
const imagefs = await import('resin-image-fs');
const imagefs = await import('balena-image-fs');
for (const { name, content } of files) {
await imagefs.writeFile(
{
image,
partition: BOOT_PARTITION,
path: path.join(CONNECTIONS_FOLDER, name),
},
content,
);
await imagefs.interact(image, BOOT_PARTITION, async (_fs) => {
return await promisify(_fs.writeFile)(
path.join(CONNECTIONS_FOLDER, name),
content,
);
});
console.info(`Copied system-connection file: ${name}`);
}
}
@ -297,19 +297,6 @@ export default class OsConfigureCmd extends Command {
}
async function validateOptions(options: FlagsDef) {
if (process.platform === 'win32') {
throw new ExpectedError(stripIndent`
Unsupported platform error: the 'balena os configure' command currently requires
the Windows Subsystem for Linux in order to run on Windows. It was tested with
the Ubuntu 18.04 distribution from the Microsoft Store. With WSL, a balena CLI
release for Linux (rather than Windows) should be installed: for example, the
standalone zip package for Linux. (It is possible to have both a Windows CLI
release and a Linux CLI release installed simultaneously.) For more information
on WSL and the balena CLI installation options, please check:
- https://docs.microsoft.com/en-us/windows/wsl/about
- https://github.com/balena-io/balena-cli/blob/master/INSTALL.md
`);
}
// The 'device' and 'application' options are declared "exclusive" in the oclif
// flag definitions above, so oclif will enforce that they are not both used together.
if (!options.device && !options.application) {

View File

@ -43,7 +43,9 @@ export default class UtilAvailableDrivesCmd extends Command {
const sdk = await import('etcher-sdk');
const adapter = new sdk.scanner.adapters.BlockDeviceAdapter(() => false);
const adapter = new sdk.scanner.adapters.BlockDeviceAdapter({
includeSystemDrives: () => false,
});
const scanner = new sdk.scanner.Scanner([adapter]);
await scanner.start();

1729
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -197,8 +197,9 @@
"@zeit/dockerignore": "0.0.3",
"JSONStream": "^1.0.3",
"balena-config-json": "^4.1.0",
"balena-device-init": "^5.0.2",
"balena-device-init": "^6.0.0",
"balena-errors": "^4.7.1",
"balena-image-fs": "^7.0.6",
"balena-image-manager": "^7.0.3",
"balena-preload": "^10.4.1",
"balena-release": "^3.0.0",
@ -222,7 +223,7 @@
"docker-toolbelt": "^3.3.8",
"dockerode": "^2.5.8",
"ejs": "^3.1.3",
"etcher-sdk": "^2.0.20",
"etcher-sdk": "^6.2.0",
"event-stream": "3.3.4",
"express": "^4.13.3",
"fast-boot2": "^1.1.0",
@ -250,13 +251,12 @@
"patch-package": "^6.4.7",
"prettyjson": "^1.1.3",
"progress-stream": "^2.0.0",
"reconfix": "^0.1.0",
"reconfix": "^1.0.0-v0-1-0-fork-46760acff4d165f5238bfac5e464256ef1944476",
"request": "^2.88.2",
"resin-cli-form": "^2.0.2",
"resin-cli-visuals": "^1.7.0",
"resin-cli-visuals": "^1.8.0",
"resin-compose-parse": "^2.1.2",
"resin-doodles": "^0.1.1",
"resin-image-fs": "^5.0.9",
"resin-multibuild": "^4.7.2",
"resin-stream-logger": "^0.1.2",
"rimraf": "^3.0.2",
@ -277,7 +277,7 @@
"window-size": "^1.1.0"
},
"optionalDependencies": {
"net-keepalive": "^1.3.6",
"net-keepalive": "^2.0.3",
"windosu": "^0.3.0"
}
}

View File

@ -2,7 +2,7 @@ import { expect } from 'chai';
import { promises as fs } from 'fs';
import * as process from 'process';
import { runCommand } from '../../helpers';
import { promisify } from 'bluebird';
import { promisify } from 'util';
import * as tmp from 'tmp';
tmp.setGracefulCleanup();
@ -48,16 +48,14 @@ if (process.platform !== 'win32') {
expect(err.join('')).to.equal('');
// confirm the image contains a config.json...
const imagefs = await require('resin-image-fs');
const config = await imagefs.readFile({
image: tmpPath,
partition: 1,
path: '/config.json',
const imagefs = await import('balena-image-fs');
const config = await imagefs.interact(tmpPath, 1, async (_fs) => {
return await promisify(_fs.readFile)('/config.json');
});
expect(config).to.not.be.empty;
// confirm the image has the correct config.json values...
const configObj = JSON.parse(config);
const configObj = JSON.parse(config.toString('utf8'));
expect(configObj).to.have.property('deviceType', 'raspberrypi3');
expect(configObj).to.have.property('initialDeviceName', 'testDeviceName');
});

View File

@ -39,6 +39,9 @@ interface TestOutput {
* @param testOutput
*/
function filterCliOutputForTests(testOutput: TestOutput): TestOutput {
const {
matchesNodeEngineVersionWarn,
} = require('../automation/utils') as typeof import('../automation/utils');
return {
exitCode: testOutput.exitCode,
err: testOutput.err.filter(
@ -48,8 +51,7 @@ function filterCliOutputForTests(testOutput: TestOutput): TestOutput {
// sdk.setSharedOptions multiple times in the same process
!line.startsWith('Shared SDK options') &&
!line.startsWith('WARN: disabling Sentry.io error reporting') &&
// Node 12: '[DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated'
!line.includes('[DEP0066]'),
!matchesNodeEngineVersionWarn(line),
),
out: testOutput.out.filter((line: string) => !line.match(/\[debug\]/i)),
};

View File

@ -24,6 +24,50 @@
The file must be distributed with executable as %2.
%1: node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
%1: node_modules/@ronomon/direct-io/binding.node
%2: path-to-executable/binding.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/build/Release/drivelist.node
%2: path-to-executable/drivelist.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/darwin.sh
%2: path-to-executable/drivelist/darwin.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/linux.sh
%2: path-to-executable/drivelist/linux.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/build/Release/drivelist.node
%2: path-to-executable/drivelist.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/darwin.sh
%2: path-to-executable/drivelist/darwin.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/linux.sh
%2: path-to-executable/drivelist/linux.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/drivelist/build/Release/drivelist.node
@ -56,14 +100,6 @@
The file must be distributed with executable as %2.
%1: node_modules/drivelist/scripts/win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
%1: node_modules/fsevents/fsevents.node

View File

@ -24,6 +24,50 @@
The file must be distributed with executable as %2.
%1: node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
%1: node_modules/@ronomon/direct-io/binding.node
%2: path-to-executable/binding.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/build/Release/drivelist.node
%2: path-to-executable/drivelist.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/darwin.sh
%2: path-to-executable/drivelist/darwin.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/linux.sh
%2: path-to-executable/drivelist/linux.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/build/Release/drivelist.node
%2: path-to-executable/drivelist.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/darwin.sh
%2: path-to-executable/drivelist/darwin.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/linux.sh
%2: path-to-executable/drivelist/linux.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/etcher-sdk/node_modules/drivelist/scripts/win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/drivelist/build/Release/drivelist.node
@ -56,14 +100,6 @@
The file must be distributed with executable as %2.
%1: node_modules/drivelist/scripts/win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules/patch-package/node_modules/open/xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
%1: node_modules/xxhash/build/Release/hash.node

View File

@ -26,6 +26,50 @@
The file must be distributed with executable as %2.
%1: node_modules\open\xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
%1: node_modules\@ronomon\direct-io\binding.node
%2: path-to-executable/binding.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\build\Release\drivelist.node
%2: path-to-executable/drivelist.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\scripts\darwin.sh
%2: path-to-executable/drivelist/darwin.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\scripts\linux.sh
%2: path-to-executable/drivelist/linux.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\scripts\win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\build\Release\drivelist.node
%2: path-to-executable/drivelist.node
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\scripts\darwin.sh
%2: path-to-executable/drivelist/darwin.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\scripts\linux.sh
%2: path-to-executable/drivelist/linux.sh
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\etcher-sdk\node_modules\drivelist\scripts\win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\patch-package\node_modules\open\xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\patch-package\node_modules\open\xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\drivelist\build\Release\drivelist.node
@ -58,14 +102,6 @@
The file must be distributed with executable as %2.
%1: node_modules\drivelist\scripts\win32.bat
%2: path-to-executable/drivelist/win32.bat
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\patch-package\node_modules\open\xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include file %1 into executable.
The file must be distributed with executable as %2.
%1: node_modules\patch-package\node_modules\open\xdg-open
%2: path-to-executable/xdg-open
> Warning Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
%1: node_modules\xxhash\build\Release\hash.node

View File

@ -62,7 +62,6 @@ describe('convertEolInPlace() function', function () {
describe('detectEncoding() function', function () {
it('should correctly detect the encoding of a few selected files', async () => {
const sampleBinary = [
'ext2fs/build/Release/bindings.node',
'drivelist/build/Release/drivelist.node',
'@balena.io/usb/build/Release/usb_bindings.node',
'xxhash/build/Release/hash.node',

View File

@ -1,39 +0,0 @@
/**
* @license
* Copyright 2019 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare module 'resin-image-fs' {
import Bluebird = require('bluebird');
export interface ImageDefinition {
image: string;
partition: number;
path: string;
}
export function readFile(options: {}): Bluebird<string>;
export function writeFile(
definition: ImageDefinition,
contents: string,
): Bluebird<void>;
export function copy(
input: ImageDefinition,
output: ImageDefinition,
): Bluebird<void>;
export function listDirectory(
definition: ImageDefinition,
): Bluebird<string[]>;
}