Skip to content

Commit e2dcfff

Browse files
committed
Lib: Ensure that every task that relies on the CWD sets it first
Before, tasks implicitly relied on the CWD being correct. This actually broke the _pushBranch task, which assumed to run in the repo directory. Since the CDN related tasks change the CWD, that wasn't correct anymore. In the future, all tasks that depend on the correct CWD need to expliclty set it first. Fixes #14
1 parent f85ecb1 commit e2dcfff

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

lib/cdn.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = function( Release ) {
1010
remote = Release.isTest ? testRemote : realRemote;
1111

1212
console.log( "Cloning " + remote.cyan + "..." );
13+
Release.chdir( Release.dir.base );
1314
Release.git( "clone " + remote + " " + local, "Error cloning CDN repo." );
1415
console.log();
1516

@@ -33,11 +34,12 @@ module.exports = function( Release ) {
3334
projectCdn = jqueryCdn + "/" + Release.project + "/" + Release.newVersion;
3435
}
3536

37+
Release.chdir( Release.dir.base );
3638
shell.mkdir( "-p", projectCdn );
3739
shell.cp( "-r", releaseCdn + "/*", projectCdn );
3840

3941
console.log( "Adding files..." );
40-
process.chdir( projectCdn );
42+
Release.chdir( projectCdn );
4143
Release.git( "add ." , "Error adding files." );
4244
Release.git( "commit -m '" + commitMessage + "'" , "Error commiting files." );
4345
Release.git( "push", "Error pushing to CDN." );

lib/changelog.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Release.define({
2626
"https://github.com/jquery/" + Release.project + "/issue/";
2727

2828
console.log( "Adding commits..." );
29+
Release.chdir( Release.dir.repo );
2930
commits = Release.gitLog( fullFormat );
3031

3132
console.log( "Adding links to tickets..." );

lib/contributors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Release.define({
1616
contributorsPath = Release.dir.base + "/contributors.txt";
1717

1818
console.log( "Adding committers and authors..." );
19+
Release.chdir( Release.dir.repo );
1920
contributors = Release.gitLog( "%aN%n%cN" );
2021

2122
console.log( "Adding reporters and commenters from issues..." );

lib/repo.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ module.exports = function( Release ) {
55
Release.define({
66
_jsonFiles: [ "package.json", "bower.json" ],
77
_cloneRepo: function() {
8+
Release.chdir( Release.dir.base );
89
console.log( "Cloning " + Release.remote.cyan + "..." );
910
Release.git( "clone " + Release.remote + " " + Release.dir.repo, "Error cloning repo." );
10-
process.chdir( Release.dir.repo );
11+
Release.chdir( Release.dir.repo );
1112

1213
console.log( "Checking out " + Release.branch.cyan + " branch..." );
1314
Release.git( "checkout " + Release.branch, "Error checking out branch." );
@@ -52,6 +53,7 @@ Release.define({
5253
.split( /\r?\n/ )
5354
.pop();
5455

56+
Release.chdir( Release.dir.repo );
5557
result = Release.exec( "grunt authors", { silent: true } );
5658
if ( result.code !== 0 ) {
5759
Release.abort( "Error getting list of authors." );
@@ -149,6 +151,7 @@ Release.define({
149151
_createReleaseBranch: function() {
150152
var json;
151153

154+
Release.chdir( Release.dir.repo );
152155
console.log( "Creating " + "release".cyan + " branch..." );
153156
Release.git( "checkout -b release", "Error creating release branch." );
154157
console.log();
@@ -178,6 +181,7 @@ Release.define({
178181
// Ensure that at least one file is in the array so that `git add` won't error
179182
paths = paths.concat( jsonFiles );
180183

184+
Release.chdir( Release.dir.repo );
181185
console.log( "Committing release artifacts..." );
182186
Release.git( "add -f " + paths.join( " " ), "Error adding release artifacts to git." );
183187
Release.git( "commit -m 'Tagging the " + Release.newVersion + " release.'",
@@ -195,11 +199,13 @@ Release.define({
195199
},
196200

197201
_pushRelease: function() {
202+
Release.chdir( Release.dir.repo );
198203
console.log( "Pushing release to git repo..." );
199204
Release.git( "push --tags", "Error pushing tags to git repo." );
200205
},
201206

202207
_updateBranchVersion: function() {
208+
Release.chdir( Release.dir.repo );
203209
console.log( "Checking out " + Release.branch.cyan + " branch..." );
204210
Release.git( "checkout " + Release.branch,
205211
"Error checking out " + Release.branch + " branch." );
@@ -214,6 +220,7 @@ Release.define({
214220
},
215221

216222
_pushBranch: function() {
223+
Release.chdir( Release.dir.repo );
217224
console.log( "Pushing " + Release.branch.cyan + " to GitHub..." );
218225
Release.git( "push", "Error pushing to GitHub." );
219226
}

lib/util.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module.exports = function( Release ) {
77
Release.define({
88
exec: shell.exec,
99

10+
chdir: function( directory ) {
11+
console.log( "Changing working directory to " + directory.cyan + "." );
12+
process.chdir( directory );
13+
},
14+
1015
abort: function( msg ) {
1116
console.log( msg.red );
1217
console.log( "Aborting.".red );

0 commit comments

Comments
 (0)