From 3bca36c2778982c1fe22367edc69604e299deeb2 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Wed, 25 Oct 2017 11:54:03 +0200 Subject: [PATCH] Allow specifying `--commit=latest` for `resin preload` Connects-To: #700 Depends-On: https://github.com/resin-io/resin-preload/pull/137 Change-Type: patch --- build/actions/preload.js | 6 ++++-- lib/actions/preload.coffee | 12 ++++++++---- package.json | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/build/actions/preload.js b/build/actions/preload.js index 8c3b27e3..76b7caf8 100644 --- a/build/actions/preload.js +++ b/build/actions/preload.js @@ -140,7 +140,7 @@ module.exports = { }, { signature: 'commit', parameter: 'hash', - description: 'a specific application commit to preload (ignored if no appId is given)', + description: 'a specific application commit to preload, use "latest" to specify the latest commit\n(ignored if no appId is given)', alias: 'c' }, { signature: 'splash-image', @@ -242,7 +242,9 @@ module.exports = { } return Promise["try"](function() { if (options.commit) { - if (!_.find(application.build, { + if (options.commit === LATEST && application.commit) { + return LATEST; + } else if (!_.find(application.build, { commit_hash: options.commit })) { expectedError('There is no build matching this commit'); diff --git a/lib/actions/preload.coffee b/lib/actions/preload.coffee index 9e9dbeb2..a9019cf8 100644 --- a/lib/actions/preload.coffee +++ b/lib/actions/preload.coffee @@ -128,7 +128,10 @@ module.exports = { signature: 'commit' parameter: 'hash' - description: 'a specific application commit to preload (ignored if no appId is given)' + description: ''' + a specific application commit to preload, use "latest" to specify the latest commit + (ignored if no appId is given) + ''' alias: 'c' } { @@ -251,13 +254,14 @@ module.exports = # Use the commit given as --commit or show an interactive commit selection menu Promise.try -> if options.commit - if not _.find(application.build, commit_hash: options.commit) + if options.commit == LATEST and application.commit + # handle `--commit latest` + return LATEST + else if not _.find(application.build, commit_hash: options.commit) expectedError('There is no build matching this commit') return options.commit selectApplicationCommit(application.build) .then (commit) -> - - # No commit specified => use the latest commit if commit == LATEST preloader.commit = application.commit else diff --git a/package.json b/package.json index 677eff19..77df5a79 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "resin-doodles": "0.0.1", "resin-image-fs": "^2.3.0", "resin-image-manager": "^5.0.0", - "resin-preload": "^4.0.2", + "resin-preload": "^4.0.9", "resin-sdk": "^7.0.0", "resin-sdk-preconfigured": "^6.9.0", "resin-settings-client": "^3.6.1", @@ -105,4 +105,4 @@ "optionalDependencies": { "removedrive": "^1.0.0" } -} \ No newline at end of file +}