scripts/create.js
function copy(from, to) {
		var mode = fs.statSync(from).mode;
		var src = fs.readFileSync(from, 'utf8');

		var re = /%([0-9A-Z\_]+)%/g;

		function replacer(_, match) {
			// We support the %PERIOD% variable to allow .gitignore to be created. The reason:
			// npm "kindly" ignores .gitignore files, so we have to use this workaround.
			// More info: https://github.com/isaacs/npm/issues/2958

			if (match === 'PERIOD') {
				return '.';
			}

			return templateRules.replace(match);
		}

		try {
			to = to.replace(re, replacer);
			src = src.replace(re, replacer);
		} catch (error) {
			pretty.warning(error + ' in: ' + from);

			// skip this file
			return;
		}

		var fd = fs.openSync(to, 'w', mode);
		fs.writeSync(fd, src);
		fs.closeSync(fd);
	}
function copy(from, to) {
		var mode = fs.statSync(from).mode;
		var src = fs.readFileSync(from, 'utf8');

		var re = /%([0-9A-Z\_]+)%/g;

		function replacer(_, match) {
			// We support the %PERIOD% variable to allow .gitignore to be created. The reason:
			// npm "kindly" ignores .gitignore files, so we have to use this workaround.
			// More info: https://github.com/isaacs/npm/issues/2958

			if (match === 'PERIOD') {
				return '.';
			}

			return templateRules.replace(match);
		}

		try {
			to = to.replace(re, replacer);
			src = src.replace(re, replacer);
		} catch (error) {
			pretty.warning(error + ' in: ' + from);

			// skip this file
			return;
		}

		var fd = fs.openSync(to, 'w', mode);
		fs.writeSync(fd, src);
		fs.closeSync(fd);
	}
function copy ( from , to ) { var mode = fs . statSync ( from ) . mode ; var src = fs . readFileSync ( from , 'utf8' ) ; var re = / %([0-9A-Z\_]+)% / g ; function replacer ( _ , match ) { // We support the %PERIOD% variable to allow .gitignore to be created. The reason: // npm "kindly" ignores .gitignore files, so we have to use this workaround. // More info: https://github.com/isaacs/npm/issues/2958 if ( match === 'PERIOD' ) { return '.' ; } return templateRules . replace ( match ) ; } try { to = to . replace ( re , replacer ) ; src = src . replace ( re , replacer ) ; } catch ( error ) { pretty . warning ( error + ' in: ' + from ) ; // skip this file return ; } var fd = fs . openSync ( to , 'w' , mode ) ; fs . writeSync ( fd , src ) ; fs . closeSync ( fd ) ; }
Copies a file from "from" to "to", and replaces template vars in filenames and file content.
@param {String} from  from-path
@param {String} to    to-path
Copies a file from from to to and replaces template vars in filenames and file content .