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 15, 2016
1 parent 4779076 commit 196855f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 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
8 changes: 4 additions & 4 deletions tests/acceptance/github-pages-deploy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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 deploy with changed defaults', function() {
Expand All @@ -106,7 +106,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 branch if needed', function() {
Expand All @@ -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 Expand Up @@ -187,7 +187,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))
.then(() => httpsStub.restore());
});

Expand Down

0 comments on commit 196855f

Please sign in to comment.