@@ -10,11 +10,28 @@ const { generate } = require('egad')
1010const kebabCase = require ( 'lodash.kebabcase' )
1111const camelCase = require ( 'lodash.camelcase' )
1212const chalk = require ( 'chalk' )
13+ const jsesc = require ( 'jsesc' )
1314const spawn = require ( 'cross-spawn' )
1415const stringifyAuthor = require ( 'stringify-author' )
1516const { guessEmail, guessAuthor, guessGitHubUsername } = require ( 'conjecture' )
1617const validatePackageName = require ( 'validate-npm-package-name' )
1718
19+ /**
20+ * Partially sanitizes keys by escaping double-quotes.
21+ *
22+ * @param {Object } object The object to mutate.
23+ * @param {String[] } keys The keys on `object` to sanitize.
24+ */
25+ function sanitizeBy ( object , keys ) {
26+ keys . forEach ( key => {
27+ if ( key in object ) {
28+ object [ key ] = jsesc ( object [ key ] , {
29+ quotes : 'double'
30+ } )
31+ }
32+ } )
33+ }
34+
1835program
1936 . usage ( '[options] [destination]' )
2037 . option ( '-n, --appName <app-name>' , 'App name' )
@@ -133,6 +150,8 @@ inquirer.prompt(prompts)
133150 answers . template = program . template || answers . template
134151
135152 // TODO: clean that up into nicer object combinging
153+
154+ sanitizeBy ( answers , [ 'author' , 'description' ] )
136155
137156 if ( ! templates . includes ( answers . template ) ) {
138157 console . log ( chalk . red ( `Please use an existing use case template: ${ templates . join ( ', ' ) } ` ) )
0 commit comments