node-raspberrypi-usbboot
Advanced tools
Comparing version 1.1.0-build-aethernet-allow-custom-sb-assets-900d62a628cac2346f4a3d1ea05466aef3689b64-1 to 1.1.0-build-aethernet-allow-custom-sb-assets-bbd5392aa27ada26a0647cd0dc3308bd1a3eb330-1
@@ -251,5 +251,19 @@ "use strict"; | ||
}; | ||
const safeReadFile = async (filename) => { | ||
const getFileBuffer = async (device, filename, extraFolder) => { | ||
try { | ||
return await (0, promises_1.readFile)(Path.join(__dirname, '..', 'blobs', filename)); | ||
if (extraFolder) { | ||
const extraBuffer = await (0, promises_1.readFile)(Path.join(extraFolder, filename)); | ||
if (extraBuffer !== undefined) { | ||
debug(`Sending buffer from ${extraFolder}/${filename}`); | ||
return extraBuffer; | ||
} | ||
} | ||
const folder = device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2711_BOOT | ||
? 'cm4' | ||
: 'raspberrypi'; | ||
const buffer = await (0, promises_1.readFile)(Path.join(__dirname, '..', 'blobs', folder, filename)); | ||
if (buffer === undefined) { | ||
debug("Can't read file", filename); | ||
} | ||
return buffer; | ||
} | ||
@@ -260,27 +274,2 @@ catch (e) { | ||
}; | ||
const unsafeReadFile = async (filename) => { | ||
try { | ||
return await (0, promises_1.readFile)(filename); | ||
} | ||
catch (e) { | ||
// no data | ||
} | ||
}; | ||
const getFileBuffer = async (device, filename, extraFolder) => { | ||
if (extraFolder) { | ||
const extraBuffer = await unsafeReadFile(Path.join(extraFolder, filename)); | ||
if (extraBuffer !== undefined) { | ||
debug(`Sending buffer from ${extraFolder}/${filename}`); | ||
return extraBuffer; | ||
} | ||
} | ||
const folder = device.deviceDescriptor.idProduct === USB_PRODUCT_ID_BCM2711_BOOT | ||
? 'cm4' | ||
: 'raspberrypi'; | ||
const buffer = await safeReadFile(Path.join(folder, filename)); | ||
if (buffer === undefined) { | ||
debug("Can't read file", filename); | ||
} | ||
return buffer; | ||
}; | ||
/** | ||
@@ -287,0 +276,0 @@ * @summary Create a boot message buffer |
@@ -8,3 +8,3 @@ # Change Log | ||
# v1.1.0 | ||
## (2024-05-09) | ||
## (2024-06-07) | ||
@@ -11,0 +11,0 @@ * minor: allow passing custom assets to start SB protected CM4 [Edwin Joassart] |
{ | ||
"name": "node-raspberrypi-usbboot", | ||
"version": "1.1.0-build-aethernet-allow-custom-sb-assets-900d62a628cac2346f4a3d1ea05466aef3689b64-1", | ||
"version": "1.1.0-build-aethernet-allow-custom-sb-assets-bbd5392aa27ada26a0647cd0dc3308bd1a3eb330-1", | ||
"description": "Transforms Raspberry Pi Compute Modules and Zeros to mass storage devices.", | ||
@@ -33,7 +33,7 @@ "main": "build/index.js", | ||
"devDependencies": { | ||
"@balena/lint": "8.0.1", | ||
"@balena/lint": "8.0.2", | ||
"@types/debug": "^4.1.12", | ||
"@types/node": "^20.12.7", | ||
"node-gyp-build": "^4.8.0", | ||
"rimraf": "^5.0.5", | ||
"@types/node": "^20.12.12", | ||
"node-gyp-build": "^4.8.1", | ||
"rimraf": "^5.0.7", | ||
"ts-node": "^10.9.2", | ||
@@ -43,4 +43,4 @@ "typescript": "^5.4.5" | ||
"versionist": { | ||
"publishedAt": "2024-05-09T16:33:14.678Z" | ||
"publishedAt": "2024-06-07T09:12:22.945Z" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28087530
593