Skip to content

Commit 207e339

Browse files
Ben DaviesJohannesHoppe
authored andcommitted
Added cname option
--cname has been added as an option If added it will create a 'CNAME' file enabling custom domain name usage README updated to demonstrate how to use
1 parent 8771c1c commit 207e339

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ With `--no-dotfiles` files starting with `.` are ignored.
200200

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

203+
#### <a id="cname">--cname</a>
204+
* __optional__
205+
* Default: `No CNAME file is generated`
206+
* Example:
207+
* `ngh --cname=example.com`
203208

209+
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/).
204210

205211
## FAQ
206212

bin/angular-cli-ghpages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ program
1515
.option('-e, --email <email>', 'The git user-email which is associated with this commit')
1616
.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!')
1717
.option('-T, --no-dotfiles', 'Includes dotfiles by default. When set files starting with `.` are ignored.')
18+
.option('-c, --cname <domain>', 'Generate a CNAME for the specified domain')
1819
.option('--dry-run', 'For testing: Run through without making any changes.')
1920
.parse(process.argv);
2021

index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,23 @@ exports.run = function (options) {
8787
user: options.user || 'undefined: local or gloabl git username & email properties will be taken',
8888
noSilent: options.noSilent || 'undefined: logging is in silent mode by default',
8989
noDotfiles: options.noDotfiles || 'undefined: dotfiles are included by default',
90-
dryRun: options.dryRun
90+
dryRun: options.dryRun,
91+
cname: options.cname || 'undefined: no CNAME file will be created',
9192
});
9293
return;
9394
}
9495

96+
if (options.cname) {
97+
console.log('CNAME option is present with value: ' + options.cname);
98+
fs.writeFile(dir + '/CNAME', options.cname, function (err) {
99+
if (err) {
100+
console.log(err);
101+
} else {
102+
console.log('CNAME file created');
103+
}
104+
})
105+
}
106+
95107
return publish(dir, options)
96108
})
97109
.then(function showSuccess() {

0 commit comments

Comments
 (0)