Skip to content

Commit

Permalink
Fix yarn run sync --<project>_ref= command
Browse files Browse the repository at this point in the history
Was supposed to be fixed in #229 but lost a few commits. We fix
the snakecasing done by commander.js there but don't set
the ref correctly because the name differs from what is set
by lib/config.js. This adds a parameter to the projects
config to specify what should be used for the command line
arg (defaults to name.replace('-', '_').

Fixes #299
  • Loading branch information
RyanJarv committed Jun 7, 2018
1 parent 2633dc1 commit 889b15e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ Config.prototype.buildProjects = function () {
url: getNPMConfig(['projects', projectName, 'repository', 'url']),
gclientName: getNPMConfig(['projects', projectName, 'dir']),
dir: path.join(this.rootDir, getNPMConfig(['projects', projectName, 'dir'])),
custom_deps: packages.config.projects[projectName].custom_deps
custom_deps: packages.config.projects[projectName].custom_deps,
arg_name: projectName.replace('-', '_')
}
})
}
Expand Down Expand Up @@ -239,12 +240,13 @@ Config.prototype.update = function (options) {

this.projectNames.forEach((projectName) => {
// don't update refs for projects that have them
if (!this.projects[projectName].ref)
let project = this.projects[projectName]
if (!project.ref)
return

let ref = options[projectName + '_ref']
let ref = options[project.arg_name + '_ref']
if (ref && ref !== 'default' && ref !== '') {
this.projects[projectName].ref = ref
project.ref = ref
}
})
}
Expand Down
13 changes: 7 additions & 6 deletions scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ program
.option('--submodule_sync', 'run submodule sync')
.option('--init', 'initialize all dependencies')
.option('--all', 'update all projects')
projectNames.forEach((project) => {
project = project.replace('-', '_')
program.option('--' + project + '_ref <ref>', project + ' ref to checkout')
projectNames.forEach((name) => {
let project = config.projects[name]
program.option('--' + project.arg_name + '_ref <ref>', name + ' ref to checkout')
})

program.parse(process.argv)
Expand All @@ -37,10 +37,11 @@ if (program.init) {

let updatedVersion = false

projectNames.forEach((project) => {
if (program.init || program.all || program[project.replace('-', '_') + '_ref']) {
projectNames.forEach((name) => {
let project = config.projects[name]
if (program.init || program.all || program[project.arg_name + '_ref']) {
updatedVersion = true
util.setDepVersion(config.projects[project].dir, config.projects[project].ref)
util.setDepVersion(project.dir, project.ref)
}
})

Expand Down

0 comments on commit 889b15e

Please sign in to comment.