From cedcc3e9186bb295946ee19af60bb53061eb6c70 Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Mon, 30 May 2016 21:19:12 -0400 Subject: [PATCH 1/2] fix(deploy): Fix base href for user pages Deploying to user pages would change the base URL to something like "/angular.github.io/" instead of the correct "/" due to the URL structure for user pages. --- addon/ng2/commands/github-pages-deploy.ts | 6 ++++-- tests/acceptance/github-pages-deploy.spec.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addon/ng2/commands/github-pages-deploy.ts b/addon/ng2/commands/github-pages-deploy.ts index 2c4803e5dc08..f53279238c97 100644 --- a/addon/ng2/commands/github-pages-deploy.ts +++ b/addon/ng2/commands/github-pages-deploy.ts @@ -162,12 +162,13 @@ module.exports = Command.extend({ if (file === '.gitignore'){ // don't overwrite the .gitignore file return Promise.resolve(); - } + } return fsCopy(path.join('dist', file), path.join('.', file)) }))); } function updateBaseHref() { + if (options.userPage) return Promise.resolve(); let indexHtml = path.join(root, 'index.html'); return fsReadFile(indexHtml, 'utf8') .then((data) => data.replace(//g, ``)) @@ -192,7 +193,8 @@ module.exports = Command.extend({ return execPromise('git remote -v') .then((stdout) => { let userName = stdout.match(/origin\s+(?:https:\/\/|git@)github\.com(?:\:|\/)([^\/]+)/m)[1].toLowerCase(); - ui.writeLine(chalk.green(`Deployed! Visit https://${userName}.github.io/${projectName}/`)); + let url = `https://${userName}.github.io/${options.userPage ? '' : (projectName + '/')}`; + ui.writeLine(chalk.green(`Deployed! Visit ${url}`)); ui.writeLine('Github pages might take a few minutes to show the deployed site.'); }); } diff --git a/tests/acceptance/github-pages-deploy.spec.js b/tests/acceptance/github-pages-deploy.spec.js index 7f1f7d57ecfd..2a23183c8dc7 100644 --- a/tests/acceptance/github-pages-deploy.spec.js +++ b/tests/acceptance/github-pages-deploy.spec.js @@ -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(``)).to.not.equal(-1)); + .then((data) => expect(data.search(``)).to.not.equal(-1)); }); it('should create branch if needed', function() { From 77a72b88bc067d286a831779541de0a191401715 Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Tue, 31 May 2016 17:45:12 -0600 Subject: [PATCH 2/2] style(lint): use single quotes for string --- tests/acceptance/github-pages-deploy.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/github-pages-deploy.spec.js b/tests/acceptance/github-pages-deploy.spec.js index 2a23183c8dc7..efee8e5d2014 100644 --- a/tests/acceptance/github-pages-deploy.spec.js +++ b/tests/acceptance/github-pages-deploy.spec.js @@ -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(``)).to.not.equal(-1)); + .then((data) => expect(data.search('')).to.not.equal(-1)); }); it('should create branch if needed', function() {