config.requires = function() { var p = grunt.util.pluralize; var props = grunt.util.toArray(arguments).map(config.getPropString); var msg = 'Verifying propert' + p(props.length, 'y/ies') + ' ' + grunt.log.wordlist(props) + ' exist' + p(props.length, 's') + ' in config...'; grunt.verbose.write(msg); var failProps = config.data && props.filter(function(prop) { return config.get(prop) == null; }).map(function(prop) { return '"' + prop + '"'; }); if (config.data && failProps.length === 0) { grunt.verbose.ok(); return true; } else { grunt.verbose.or.write(msg); grunt.log.error().error('Unable to process task.'); if (!config.data) { throw grunt.util.error('Unable to load config.'); } else { throw grunt.util.error('Required config propert' + p(failProps.length, 'y/ies') + ' ' + failProps.join(', ') + ' missing.'); } } };
Utils.readFileSync = function (filepath, opts) { var contents; opts = opts || {}; opts.defaultEncoding = 'utf8'; try { contents = fs.readFileSync(String(filepath)); // If encoding is not explicitly null, convert from encoded buffer to a // string. If no encoding was specified, use the default. if (opts.encoding !== null) { contents = iconv.decode(contents, opts.encoding || opts.defaultEncoding); // Strip any BOM that might exist. if (contents.charCodeAt(0) === 0xFEFF) { contents = contents.substring(1); } } grunt.verbose.ok(); return contents; } catch (e) { grunt.verbose.error(); throw grunt.util.error('Unable to read "' + filepath + '" file (Error code: ' + e.code + ').', e); } };
.catch(function (e) { grunt.verbose.error(); throw grunt.util.error('Unable to write "' + path.replace(cwd, '.') + '" file (' + e.message + ').', e); })