Skip to content

Commit bebedae

Browse files
committed
Fix yarn run sync --<project>_ref= command
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
1 parent 8fdc550 commit bebedae

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

build/lib/config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ Config.prototype.buildProjects = function () {
176176
url: getNPMConfig(['projects', projectName, 'repository', 'url']),
177177
gclientName: getNPMConfig(['projects', projectName, 'dir']),
178178
dir: path.join(this.rootDir, getNPMConfig(['projects', projectName, 'dir'])),
179-
custom_deps: packages.config.projects[projectName].custom_deps
179+
custom_deps: packages.config.projects[projectName].custom_deps,
180+
arg_name: projectName.replace('-', '_')
180181
}
181182
})
182183
}
@@ -239,12 +240,13 @@ Config.prototype.update = function (options) {
239240

240241
this.projectNames.forEach((projectName) => {
241242
// don't update refs for projects that have them
242-
if (!this.projects[projectName].ref)
243+
let project = this.projects[projectName]
244+
if (!project.ref)
243245
return
244246

245-
let ref = options[projectName + '_ref']
247+
let ref = options[project.arg_name + '_ref']
246248
if (ref && ref !== 'default' && ref !== '') {
247-
this.projects[projectName].ref = ref
249+
project.ref = ref
248250
}
249251
})
250252
}

build/scripts/sync.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ program
1515
.option('--submodule_sync', 'run submodule sync')
1616
.option('--init', 'initialize all dependencies')
1717
.option('--all', 'update all projects')
18-
projectNames.forEach((project) => {
19-
project = project.replace('-', '_')
20-
program.option('--' + project + '_ref <ref>', project + ' ref to checkout')
18+
projectNames.forEach((name) => {
19+
let project = config.projects[name]
20+
program.option('--' + project.arg_name + '_ref <ref>', name + ' ref to checkout')
2121
})
2222

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

3838
let updatedVersion = false
3939

40-
projectNames.forEach((project) => {
41-
if (program.init || program.all || program[project.replace('-', '_') + '_ref']) {
40+
projectNames.forEach((name) => {
41+
let project = config.projects[name]
42+
if (program.init || program.all || program[project.arg_name + '_ref']) {
4243
updatedVersion = true
43-
util.setDepVersion(config.projects[project].dir, config.projects[project].ref)
44+
util.setDepVersion(project.dir, project.ref)
4445
}
4546
})
4647

0 commit comments

Comments
 (0)