Skip to content

Added cname option #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ With `--no-dotfiles` files starting with `.` are ignored.

Run through without making any changes. This can be very usefull, because it outputs what would happend without doing anything.

#### <a id="cname">--cname</a>
* __optional__
* Default: `No CNAME file is generated`
* Example:
* `ngh --cname=example.com`

A CNAME file will be created enabling you to use a custom domain. [More information on Github Pages using a custom domain](https://help.github.com/articles/using-a-custom-domain-with-github-pages/).

## FAQ

Expand Down
1 change: 1 addition & 0 deletions bin/angular-cli-ghpages
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ program
.option('-e, --email <email>', 'The git user-email which is associated with this commit')
.option('-S, --no-silent', 'Logging is in silent mode by default. The option enables extended console logging. Keep this untouched if the repository URL or other information passed to git commands is sensitive!')
.option('-T, --no-dotfiles', 'Includes dotfiles by default. When set files starting with `.` are ignored.')
.option('-c, --cname <domain>', 'Generate a CNAME for the specified domain')
.option('--dry-run', 'For testing: Run through without making any changes.')
.parse(process.argv);

Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,23 @@ exports.run = function (options) {
user: options.user || 'undefined: local or gloabl git username & email properties will be taken',
noSilent: options.noSilent || 'undefined: logging is in silent mode by default',
noDotfiles: options.noDotfiles || 'undefined: dotfiles are included by default',
dryRun: options.dryRun
dryRun: options.dryRun,
cname: options.cname || 'undefined: no CNAME file will be created',
});
return;
}

if (options.cname) {
console.log('CNAME option is present with value: ' + options.cname);
fs.writeFile(path.join(dir, 'CNAME'), options.cname, function (err) {
if (err) {
console.log(err);
} else {
console.log('CNAME file created');
}
})
}

return publish(dir, options)
})
.then(function showSuccess() {
Expand Down