Skip to content

Commit b6d64ef

Browse files
committed
Firmware sync now grabs settings for flashing.
1 parent e34de22 commit b6d64ef

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

scripts/update-firmware-binaries.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const settings = require('../src/settings');
1010
const GITHUB_USER = 'spark';
1111
const GITHUB_FIRMWARE_REPOSITORY = 'firmware';
1212
const GITHUB_CLI_REPOSITORY = 'particle-cli';
13-
const SETTINGS_FILE = settings.BINARIES_DIRECTORY + '/settings.json';
13+
const SPECIFICATIONS_FILE = settings.BINARIES_DIRECTORY + '/specifications.js';
14+
const SETTINGS_FILE = settings.BINARIES_DIRECTORY + '/settings.js';
1415

1516
// This default is here so that the regex will work when updating these files.
1617
const DEFAULT_SETTINGS = {
@@ -91,7 +92,7 @@ const updateSettings = () => {
9192
if (!fs.exists(SETTINGS_FILE)) {
9293
fs.writeFileSync(
9394
SETTINGS_FILE,
94-
JSON.stringify(DEFAULT_SETTINGS, null, 2),
95+
`module.exports = ${JSON.stringify(DEFAULT_SETTINGS, null, 2)};`,
9596
{ flag: 'wx' }
9697
);
9798
}
@@ -156,7 +157,7 @@ const clearBinariesPromise = cleanBinariesDirectory().then(() => {
156157
const appPromise = clearBinariesPromise.then(() => downloadAppBinaries());
157158

158159
// Download firmware binaries
159-
const promise = clearBinariesPromise.then(
160+
const firmwarePromise = clearBinariesPromise.then(
160161
() => process.argv.length !== 3
161162
? githubAPI.repos.getTags({
162163
owner: GITHUB_USER,
@@ -190,7 +191,7 @@ const promise = clearBinariesPromise.then(
190191
})
191192
);
192193

193-
promise.then(release => {
194+
firmwarePromise.then(release => {
194195
return downloadFirmwareBinaries(release.assets);
195196
})
196197
.then(downloadedBinaries => ({
@@ -199,6 +200,18 @@ promise.then(release => {
199200
}))
200201
.then(fileData => verifyBinariesMatch(fileData));
201202

202-
Promise.all([appPromise, promise])
203+
const specificationsPromise = githubAPI.repos.getContent({
204+
owner: GITHUB_USER,
205+
path: 'lib/deviceSpecs/specifications.js',
206+
repo: GITHUB_CLI_REPOSITORY
207+
}).then(response => {
208+
fs.writeFileSync(
209+
SPECIFICATIONS_FILE,
210+
new Buffer(response.content, 'base64').toString(),
211+
{ flag: 'wx' }
212+
);
213+
})
214+
215+
Promise.all([appPromise, firmwarePromise, specificationsPromise])
203216
.then(() => console.log('\r\nCompleted Sync'))
204217
.catch(console.log);

0 commit comments

Comments
 (0)