From 2c46c59a796d1ebee016c9c900abe45324880a8a Mon Sep 17 00:00:00 2001
From: Tim Perry <pimterry@gmail.com>
Date: Mon, 30 Apr 2018 10:24:43 +0200
Subject: [PATCH] Update resin-image-fs to stop non-config commands failing in
 node 10

This doesn't fix actual usage of image fs, just makes it possible to
stop commands that don't use it from failing entirely.

Connects-To: #869
Change-Type: patch
---
 lib/actions/local/configure.coffee | 8 +++++---
 lib/utils/helpers.ts               | 8 ++------
 package.json                       | 2 +-
 typings/resin-image-fs.d.ts        | 2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/lib/actions/local/configure.coffee b/lib/actions/local/configure.coffee
index a35fbe77..51cdf9e8 100644
--- a/lib/actions/local/configure.coffee
+++ b/lib/actions/local/configure.coffee
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 ###
 
-BOOT_PARTITION = { primary: 1 }
+BOOT_PARTITION = 1
 CONNECTIONS_FOLDER = '/system-connections'
 
 getConfigurationSchema = (connnectionFileName = 'resin-wifi') ->
@@ -51,12 +51,14 @@ getConfigurationSchema = (connnectionFileName = 'resin-wifi') ->
 			type: 'ini'
 			location:
 				path: CONNECTIONS_FOLDER.slice(1)
-				partition: BOOT_PARTITION
+				# Reconfix still uses the older resin-image-fs, so still needs an
+				# object-based partition definition.
+				partition: { primary: BOOT_PARTITION }
 		config_json:
 			type: 'json'
 			location:
 				path: 'config.json'
-				partition: BOOT_PARTITION
+				partition: { primary: BOOT_PARTITION }
 
 inquirerOptions = (data) -> [
 	{
diff --git a/lib/utils/helpers.ts b/lib/utils/helpers.ts
index 88bbfcf9..4f3d0d95 100644
--- a/lib/utils/helpers.ts
+++ b/lib/utils/helpers.ts
@@ -26,7 +26,6 @@ import ResinSdk = require('resin-sdk');
 import { execute } from 'president';
 import { InitializeEmitter, OperationState } from 'resin-device-init';
 
-const extractStreamAsync = Promise.promisify(rindle.extract);
 const waitStreamAsync = Promise.promisify(rindle.wait);
 const presidentExecuteAsync = Promise.promisify(execute);
 
@@ -82,14 +81,11 @@ export function getManifest(
 	// partition, but fallback to the API if
 	// we encounter any errors along the way.
 	return imagefs
-		.read({
+		.readFile({
 			image,
-			partition: {
-				primary: 1,
-			},
+			partition: 1,
 			path: '/device-type.json',
 		})
-		.then(extractStreamAsync)
 		.then(JSON.parse)
 		.catch(() => resin.models.device.getManifestBySlug(deviceType));
 }
diff --git a/package.json b/package.json
index 8936c88d..1f9991f2 100644
--- a/package.json
+++ b/package.json
@@ -141,7 +141,7 @@
     "resin-device-init": "^4.0.0",
     "resin-docker-build": "^0.6.2",
     "resin-doodles": "0.0.1",
-    "resin-image-fs": "^2.3.0",
+    "resin-image-fs": "^5.0.2",
     "resin-image-manager": "^5.0.0",
     "resin-multibuild": "^0.5.1",
     "resin-preload": "^6.2.0",
diff --git a/typings/resin-image-fs.d.ts b/typings/resin-image-fs.d.ts
index 00f85d54..ad1c0879 100644
--- a/typings/resin-image-fs.d.ts
+++ b/typings/resin-image-fs.d.ts
@@ -1,5 +1,5 @@
 declare module 'resin-image-fs' {
 	import Promise = require('bluebird');
 
-	export function read(options: {}): Promise<NodeJS.ReadableStream>;
+	export function readFile(options: {}): Promise<string>;
 }