grunt-videojs-languages
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "grunt-videojs-languages", | ||
"description": "A grunt task to convert video.js language JSON files in to includable scripts.", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"homepage": "https://github.com/videojs/grunt-videojs-languages", | ||
@@ -6,0 +6,0 @@ "author": { |
'use strict'; | ||
var path = require('path'); | ||
var util = require('util'); | ||
@@ -8,11 +9,29 @@ module.exports = function(grunt) { | ||
this.files.forEach(function(f) { | ||
var languageName = path.basename(f.src, '.json'); | ||
var languageData = grunt.file.readJSON(f.src); | ||
var createLanguageFile = function(languageName, languageData, jsFilePath) { | ||
var jsTemplate = 'videojs.addLanguage("' + languageName + '",' + JSON.stringify(languageData,null,' ') + ');'; | ||
var jsFilePath = path.join(f.dest, languageName + '.js'); | ||
grunt.file.write(jsFilePath, jsTemplate); | ||
grunt.log.writeln('- [' + languageName +'] Language Built. File "' + jsFilePath + '" created.'); | ||
}; | ||
this.files.forEach(function(f) { | ||
var languageName, languageData, jsFilePath; | ||
// Multiple Files Case | ||
if(util.isArray(f.src)){ | ||
for(var i =0; i < f.src.length; i++) { | ||
languageName = path.basename(f.src[i], '.json'); | ||
languageData = grunt.file.readJSON(f.src[i]); | ||
jsFilePath = path.join(f.dest, languageName + '.js'); | ||
createLanguageFile(languageName, languageData, jsFilePath); | ||
} | ||
} | ||
// Singular File Case | ||
else { | ||
languageName = path.basename(f.src, '.json'); | ||
languageData = grunt.file.readJSON(f.src); | ||
jsFilePath = path.join(f.dest, languageName + '.js'); | ||
createLanguageFile(languageName, languageData, jsFilePath); | ||
} | ||
}); | ||
}); | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
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
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
21335
11
159