@@ -26,6 +26,7 @@ var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
2626var isObject = require ( '@stdlib/assert/is-object' ) ;
2727var isString = require ( '@stdlib/assert/is-string' ) . isPrimitive ;
2828var isURI = require ( '@stdlib/assert/is-uri' ) ;
29+ var format = require ( '@stdlib/string/format' ) ;
2930
3031
3132// MAIN //
@@ -56,106 +57,106 @@ var isURI = require( '@stdlib/assert/is-uri' );
5657*/
5758function validate ( opts , options ) {
5859 if ( ! isObject ( options ) ) {
59- return new TypeError ( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' ) ;
60+ return new TypeError ( format ( 'invalid argument. Options argument must be an object. Value: `%s`.' , options ) ) ;
6061 }
6162 opts . token = options . token ;
6263 if ( ! isString ( opts . token ) ) {
63- return new TypeError ( 'invalid option. `token ` option must be a string primitive. Option: `' + opts . token + '`.' ) ;
64+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive. Option: `%s`.' , 'token' , opts . token ) ) ;
6465 }
6566 if ( hasOwnProp ( options , 'useragent' ) ) {
6667 opts . useragent = options . useragent ;
6768 if ( ! isString ( opts . useragent ) ) {
68- return new TypeError ( 'invalid option. `useragent ` option must be a string primitive. Option: `' + opts . useragent + '`.' ) ;
69+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive. Option: `%s`.' , 'useragent' , opts . useragent ) ) ;
6970 }
7071 }
7172 if ( hasOwnProp ( options , 'org' ) ) {
7273 opts . org = options . org ;
7374 if ( ! isString ( opts . org ) ) {
74- return new TypeError ( 'invalid option. `org ` option must be a string primitive. Option: `' + opts . org + '`.' ) ;
75+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive. Option: `%s`.' , 'org' , opts . org ) ) ;
7576 }
7677 }
7778 if ( hasOwnProp ( options , 'desc' ) ) {
7879 opts . desc = options . desc ;
7980 if ( ! isString ( opts . desc ) ) {
80- return new TypeError ( 'invalid option. `desc ` option must be a string primitive. Option: `' + opts . desc + '`.' ) ;
81+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive. Option: `%s`.' , 'desc' , opts . desc ) ) ;
8182 }
8283 }
8384 if ( hasOwnProp ( options , 'homepage' ) ) {
8485 opts . homepage = options . homepage ;
8586 if ( ! isURI ( opts . homepage ) ) {
86- return new TypeError ( 'invalid option. `homepage ` option must be a valid URI. Option: `' + opts . homepage + '`.' ) ;
87+ return new TypeError ( format ( 'invalid option. `%s ` option must be a valid URI. Option: `%s`.' , 'homepage' , opts . homepage ) ) ;
8788 }
8889 }
8990 if ( hasOwnProp ( options , 'team' ) ) {
9091 opts . team = options . team ;
9192 if ( ! isNonNegativeInteger ( opts . team ) ) {
92- return new TypeError ( 'invalid option. `team ` option must be a nonnegative integer. Option: `' + opts . team + '`.' ) ;
93+ return new TypeError ( format ( 'invalid option. `%s ` option must be a nonnegative integer. Option: `%s`.' , 'team' , opts . team ) ) ;
9394 }
9495 }
9596 if ( hasOwnProp ( options , 'gitignore' ) ) {
9697 opts . gitignore = options . gitignore ;
9798 if ( ! isString ( opts . gitignore ) ) {
98- return new TypeError ( 'invalid option. `gitignore ` option must be a string primitive. Option: `' + opts . gitignore + '`.' ) ;
99+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive. Option: `%s`.' , 'gitignore' , opts . gitignore ) ) ;
99100 }
100101 }
101102 if ( hasOwnProp ( options , 'license' ) ) {
102103 opts . license = options . license ;
103104 if ( ! isString ( opts . license ) ) {
104- return new TypeError ( 'invalid option. `license ` option must be a string primitive. Option: `' + opts . license + '`.' ) ;
105+ return new TypeError ( format ( 'invalid option. `%s ` option must be a string primitive. Option: `%s`.' , 'license' , opts . license ) ) ;
105106 }
106107 }
107108 if ( hasOwnProp ( options , 'private' ) ) {
108109 opts . private = options . private ;
109110 if ( ! isBoolean ( opts . private ) ) {
110- return new TypeError ( 'invalid option. `private ` option must be a boolean primitive. Option: `' + opts . private + '`.' ) ;
111+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'private' , opts . private ) ) ;
111112 }
112113 }
113114 if ( hasOwnProp ( options , 'issues' ) ) {
114115 opts . issues = options . issues ;
115116 if ( ! isBoolean ( opts . issues ) ) {
116- return new TypeError ( 'invalid option. `issues ` option must be a boolean primitive. Option: `' + opts . issues + '`.' ) ;
117+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'issues' , opts . issues ) ) ;
117118 }
118119 }
119120 if ( hasOwnProp ( options , 'projects' ) ) {
120121 opts . projects = options . projects ;
121122 if ( ! isBoolean ( opts . projects ) ) {
122- return new TypeError ( 'invalid option. `projects ` option must be a boolean primitive. Option: `' + opts . wiki + '`.' ) ;
123+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'projects' , opts . projects ) ) ;
123124 }
124125 }
125126 if ( hasOwnProp ( options , 'wiki' ) ) {
126127 opts . wiki = options . wiki ;
127128 if ( ! isBoolean ( opts . wiki ) ) {
128- return new TypeError ( 'invalid option. `wiki ` option must be a boolean primitive. Option: `' + opts . wiki + '`.' ) ;
129+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'wiki' , opts . wiki ) ) ;
129130 }
130131 }
131132 if ( hasOwnProp ( options , 'downloads' ) ) {
132133 opts . downloads = options . downloads ;
133134 if ( ! isBoolean ( opts . downloads ) ) {
134- return new TypeError ( 'invalid option. `downloads ` option must be a boolean primitive. Option: `' + opts . downloads + '`.' ) ;
135+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'downloads' , opts . downloads ) ) ;
135136 }
136137 }
137138 if ( hasOwnProp ( options , 'init' ) ) {
138139 opts . init = options . init ;
139140 if ( ! isBoolean ( opts . init ) ) {
140- return new TypeError ( 'invalid option. `init ` option must be a boolean primitive. Option: `' + opts . init + '`.' ) ;
141+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'init' , opts . init ) ) ;
141142 }
142143 }
143144 if ( hasOwnProp ( options , 'allowSquashMerge' ) ) {
144145 opts . allowSquashMerge = options . allowSquashMerge ;
145146 if ( ! isBoolean ( opts . allowSquashMerge ) ) {
146- return new TypeError ( 'invalid option. `allowSquashMerge ` option must be a boolean primitive. Option: `' + opts . allowSquashMerge + '`.' ) ;
147+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'allowSquashMerge' , opts . allowSquashMerge ) ) ;
147148 }
148149 }
149150 if ( hasOwnProp ( options , 'allowMergeCommit' ) ) {
150151 opts . allowMergeCommit = options . allowMergeCommit ;
151152 if ( ! isBoolean ( opts . allowMergeCommit ) ) {
152- return new TypeError ( 'invalid option. `allowMergeCommit ` option must be a boolean primitive. Option: `' + opts . allowMergeCommit + '`.' ) ;
153+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'allowMergeCommit' , opts . allowMergeCommit ) ) ;
153154 }
154155 }
155156 if ( hasOwnProp ( options , 'allowRebaseMerge' ) ) {
156157 opts . allowRebaseMerge = options . allowRebaseMerge ;
157158 if ( ! isBoolean ( opts . allowRebaseMerge ) ) {
158- return new TypeError ( 'invalid option. `allowRebaseMerge ` option must be a boolean primitive. Option: `' + opts . allowRebaseMerge + '`.' ) ;
159+ return new TypeError ( format ( 'invalid option. `%s ` option must be a boolean primitive. Option: `%s`.' , 'allowRebaseMerge' , opts . allowRebaseMerge ) ) ;
159160 }
160161 }
161162 return null ;
0 commit comments