Skip to content

Commit

Permalink
fix(deploy): fix file copy, index tag rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed May 14, 2016
1 parent 4779076 commit 0e4778c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions addon/ng2/commands/github-pages-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,19 @@ module.exports = Command.extend({

function copyFiles() {
return fsReadDir('dist')
.then((files) => Promise.all(files.map((file) => fsCopy(path.join('dist', file), path.join('.', file)))))
.then((files) => Promise.all(files.map((file) => {
if (file === '.gitignore'){
// don't overwrite the .gitignore file
return Promise.resolve();
}
return fsCopy(path.join('dist', file), path.join('.', file))
})));
}

function updateBaseHref() {
let indexHtml = path.join(root, 'index.html');
return fsReadFile(indexHtml, 'utf8')
.then((data) => data.replace(/<base href="\/">/g, `<base href="/${projectName}/>"`))
.then((data) => data.replace(/<base href="\/">/g, `<base href="/${projectName}/">`))
.then((data) => fsWriteFile(indexHtml, data, 'utf8'));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/github-pages-deploy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('Acceptance: ng github-pages:deploy', function() {
let indexHtml = path.join(process.cwd(), 'index.html');
return fsReadFile(indexHtml, 'utf8');
})
.then((data) => expect(data.search(`<base href="/${project}/>"`)).to.not.equal(-1));
.then((data) => expect(data.search(`<base href="/${project}/">`)).to.not.equal(-1));
});

it('should create repo if needed', function() {
Expand Down

0 comments on commit 0e4778c

Please sign in to comment.