grunt-ng-html2js
Advanced tools
Comparing version 0.1.2 to 0.2.0
{ | ||
"name": "grunt-ng-html2js", | ||
"description": "Grunt wrapper for ng-html2js", | ||
"version": "v0.1.2", | ||
"version": "v0.2.0", | ||
"homepage": "https://github.com/itsnydell/grunt-ng-html2js", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -1,2 +0,2 @@ | ||
# grunt-ng-html2js v0.1.2 ![](https://ga-beacon.appspot.com/UA-60632926-1/grunt-ng-html2js/readme?pixel) | ||
# grunt-ng-html2js v0.2.0 ![](https://ga-beacon.appspot.com/UA-60632926-1/grunt-ng-html2js/readme?pixel) | ||
@@ -57,2 +57,16 @@ [![Build Status](https://travis-ci.org/itsnydell/grunt-ng-html2js.svg?branch=master)](https://travis-ci.org/itsnydell/grunt-ng-html2js) | ||
#### options.output | ||
Type: `String` | ||
Default value: `'verbose'` | ||
Available values: `'verbose'`, `'simple'`, `'none'` | ||
If you have a lot of templates to be compiled, your grunt output might get pretty crazy. You can hide every file compile message by using `'simple'` or hide all output from the task with `'none'` | ||
#### options.missingFiles | ||
Type: `String` | ||
Default value: `'warn'` | ||
Available values: `'ignore'`, `'warn'`, `'fail'` | ||
Tell grunt what to do if the file is missing. We default to just put a warning in console that the file is missing, but you can also have it ignored if you really don't care much, or fail if you want grunt to stop if the file is missing. | ||
### Usage Examples | ||
@@ -134,4 +148,5 @@ | ||
## Release History | ||
- v0.1.2 - Misc readme and package.json tweaks, no functionality updates. | ||
- v0.1.1 - Misc package tweaks, no functionality updates. | ||
- v0.2.0 - Added output verbosity and missingFile warning options | ||
- v0.1.2 - Misc readme and package.json tweaks, no functionality updates. | ||
- v0.1.1 - Misc package tweaks, no functionality updates. | ||
- v0.1.0 - First commit |
@@ -21,9 +21,17 @@ /* | ||
var options = this.options({ | ||
moduleName: null, // moduleName defaults to file name | ||
moduleVar: 'module' // moduleVar defaults to 'ngModule' | ||
}); | ||
moduleName: null, // moduleName defaults to file name | ||
moduleVar: 'module', // moduleVar defaults to 'ngModule' | ||
output: 'verbose', // 'verbose' (default) || 'simple' || 'none' | ||
missingFiles: 'warn' // 'ignore' || 'warn' (default) || 'fail' | ||
}), | ||
successCount = 0; | ||
// compile each file asynchronously | ||
// compile each file asynchronously | ||
this.files.forEach(function(file) { | ||
// If nonull isn't set, grunt errors silently, so let's not use grunt for that | ||
// Assume that if grunt silently fails, then the file doesn't exist. | ||
var fileExists = false, | ||
srcFilePath = file.src.length ? file.src : file.orig.src; | ||
// Get the file's contents | ||
@@ -34,5 +42,6 @@ var content = file.src.filter(function(filepath) { | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
// fileExists defaults to false so we don't have to do anything here | ||
return false; | ||
} else { | ||
fileExists = true; | ||
return true; | ||
@@ -48,13 +57,37 @@ } | ||
// Run ng-html2js | ||
var output = nghtml2js(file.src, content, options.moduleName, options.moduleVar); | ||
if(!fileExists) { | ||
var warnMessage = 'Source file "' + srcFilePath + '" not found.'; | ||
// Write the output file | ||
grunt.file.write(file.dest, output); | ||
switch(options.missingFiles){ | ||
case 'warn': | ||
grunt.log.warn(warnMessage); | ||
break; | ||
case 'fail': | ||
grunt.fail.warn(warnMessage); | ||
break; | ||
default: | ||
break; | ||
} | ||
} else { | ||
// Log a successful compilation | ||
grunt.log.writeln(chalk.cyan(file.src) + ' compiled to ' + chalk.cyan(file.dest)); | ||
// Run ng-html2js | ||
var output = nghtml2js(file.src, content, options.moduleName, options.moduleVar); | ||
// Write the output file | ||
grunt.file.write(file.dest, output); | ||
// Log a successful compilation | ||
if(options.output === 'verbose'){ | ||
grunt.log.writeln(chalk.cyan(file.src) + ' compiled to ' + chalk.cyan(file.dest)); | ||
} | ||
successCount++; | ||
} | ||
}); | ||
if(options.output !== 'none') { | ||
grunt.log.writeln(chalk.green( (options.output === 'verbose' ? '\n' : '') + successCount + ' of ' + this.files.length + ' templates compiled successfully.')); | ||
} | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
18133
269
151