Skip to content

Commit 196855f

Browse files
committed
fix(deploy): fix file copy, index tag rewrite
1 parent 4779076 commit 196855f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

addon/ng2/commands/github-pages-deploy.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,19 @@ module.exports = Command.extend({
149149

150150
function copyFiles() {
151151
return fsReadDir('dist')
152-
.then((files) => Promise.all(files.map((file) => fsCopy(path.join('dist', file), path.join('.', file)))))
152+
.then((files) => Promise.all(files.map((file) => {
153+
if (file === '.gitignore'){
154+
// don't overwrite the .gitignore file
155+
return Promise.resolve();
156+
}
157+
return fsCopy(path.join('dist', file), path.join('.', file))
158+
})));
153159
}
154160

155161
function updateBaseHref() {
156162
let indexHtml = path.join(root, 'index.html');
157163
return fsReadFile(indexHtml, 'utf8')
158-
.then((data) => data.replace(/<base href="\/">/g, `<base href="/${projectName}/>"`))
164+
.then((data) => data.replace(/<base href="\/">/g, `<base href="/${projectName}/">`))
159165
.then((data) => fsWriteFile(indexHtml, data, 'utf8'));
160166
}
161167

tests/acceptance/github-pages-deploy.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('Acceptance: ng github-pages:deploy', function() {
8383
let indexHtml = path.join(process.cwd(), 'index.html');
8484
return fsReadFile(indexHtml, 'utf8');
8585
})
86-
.then((data) => expect(data.search(`<base href="/${project}/>"`)).to.not.equal(-1));
86+
.then((data) => expect(data.search(`<base href="/${project}/">`)).to.not.equal(-1));
8787
});
8888

8989
it('should deploy with changed defaults', function() {
@@ -106,7 +106,7 @@ describe('Acceptance: ng github-pages:deploy', function() {
106106
let indexHtml = path.join(process.cwd(), 'index.html');
107107
return fsReadFile(indexHtml, 'utf8');
108108
})
109-
.then((data) => expect(data.search(`<base href="/${project}/>"`)).to.not.equal(-1));
109+
.then((data) => expect(data.search(`<base href="/${project}/">`)).to.not.equal(-1));
110110
});
111111

112112
it('should create branch if needed', function() {
@@ -130,7 +130,7 @@ describe('Acceptance: ng github-pages:deploy', function() {
130130
let indexHtml = path.join(process.cwd(), 'index.html');
131131
return fsReadFile(indexHtml, 'utf8');
132132
})
133-
.then((data) => expect(data.search(`<base href="/${project}/>"`)).to.not.equal(-1));
133+
.then((data) => expect(data.search(`<base href="/${project}/">`)).to.not.equal(-1));
134134
});
135135

136136
it('should create repo if needed', function() {
@@ -187,7 +187,7 @@ describe('Acceptance: ng github-pages:deploy', function() {
187187
let indexHtml = path.join(process.cwd(), 'index.html');
188188
return fsReadFile(indexHtml, 'utf8');
189189
})
190-
.then((data) => expect(data.search(`<base href="/${project}/>"`)).to.not.equal(-1))
190+
.then((data) => expect(data.search(`<base href="/${project}/">`)).to.not.equal(-1))
191191
.then(() => httpsStub.restore());
192192
});
193193

0 commit comments

Comments
 (0)