Permalink
Browse files

Merge pull request #19 from NickLarsen/master

Add command line options
  • Loading branch information...
2 parents a199b6c + 55ee359 commit 9e9cd43a47f81fc7e662e3fce662cc251b75fbaf @NickLarsen NickLarsen committed Jun 19, 2012
Showing with 18,101 additions and 32 deletions.
  1. +36 −16 src/bundler.js
  2. +1 −0 src/vs/BundlerRunOnSave/BundlerRunOnSavePackage.cs
  3. +31 −0 tests/Bootstrap.Mvc/Bootstrap.Mvc.csproj
  4. +4,686 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/app.css
  5. +3 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/app.css.bundle
  6. +4,243 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/app.js
  7. +6 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/app.js.bundle
  8. +686 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/css/bootstrap-responsive.css
  9. +3,990 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/css/bootstrap.css
  10. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/css/default.css
  11. +10 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/css/default.less
  12. BIN tests/Bootstrap.Mvc/Content-CommandLineOptions/img/glyphicons-halflings-white.png
  13. BIN tests/Bootstrap.Mvc/Content-CommandLineOptions/img/glyphicons-halflings.png
  14. +4 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/app.coffee
  15. +14 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/app.js
  16. +1,290 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/backbone.js
  17. +130 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/base.js
  18. +1,726 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/bootstrap.js
  19. +79 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/ss-validation.js
  20. +999 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/js/underscore.js
  21. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/app.css
  22. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/app.js
  23. +10 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/app.less
  24. +1 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/folder-recursive.css.bundle
  25. +1 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/folder-recursive.js.bundle
  26. +1 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/folder.css.bundle
  27. +1 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/folder.js.bundle
  28. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/something/something.js
  29. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/folder/thirdparty/thirdparty.js
  30. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/nobundle/app.css
  31. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/nobundle/app.js
  32. +10 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/nobundle/app.less
  33. +2 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/nobundle/nobundle.css.bundle
  34. +2 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/nobundle/nobundle.js.bundle
  35. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/app.css
  36. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/app.js
  37. +10 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/app.less
  38. +8 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/skipmin.css
  39. +2 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/skipmin.css.bundle
  40. +7 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/skipmin.js
  41. +2 −0 tests/Bootstrap.Mvc/Content-CommandLineOptions/options/skipmin/skipmin.js.bundle
  42. +11 −0 tests/Bootstrap.Mvc/bundler/bundler-CommandLineOptions.cmd
  43. +36 −16 tests/Bootstrap.Mvc/bundler/bundler.js
View
@@ -22,11 +22,39 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
+function clone(o) {
+ var ret = {};
+ Object.keys(o).forEach(function (val) {
+ ret[val] = o[val];
+ });
+ return ret;
+}
+String.prototype.startsWith = function (str){
+ return this.indexOf(str) === 0;
+};
+String.prototype.endsWith = function (suffix) {
+ return this.indexOf(suffix, this.length - suffix.length) !== -1;
+};
+String.prototype.endsWithAny = function (endings) {
+ var str = this;
+ return endings.some(function (ending) { return str.endsWith(ending); });
+}
+
//recursively scans the directory below for *.js.bundle and *.css.bundle files
-var SCAN_ROOT_DIRS = process.argv.splice(2); //directories specified in bundler.cmd
+var commandLineArgs = process.argv.splice(2); //directories specified in bundler.cmd
+
+var commandLineOptions = commandLineArgs.filter(function (arg) { return arg.startsWith('#'); });
+var defaultOptions = {};
+commandLineOptions.forEach(function (option) {
+ while (option.startsWith('#')) { option = option.substring(1); }
+ var parts = option.split(':');
+ defaultOptions[parts[0].toLowerCase()] = parts.length > 1 ? parts[1] : true;
+});
+
+var SCAN_ROOT_DIRS = commandLineArgs.filter(function (arg) { return !arg.startsWith('#'); });
if (!SCAN_ROOT_DIRS.length) {
console.log("No directories were specified.");
- console.log("Usage: bundler.cmd ../Content ../Scripts");
+ console.log("Usage: bundler.js [#option:value] ../Content [../Scripts]");
return;
}
@@ -41,16 +69,6 @@ var fs = require("fs"),
Step = require('step'),
startedAt = Date.now();
-String.prototype.startsWith = function (str){
- return this.indexOf(str) === 0;
-};
-String.prototype.endsWith = function (suffix) {
- return this.indexOf(suffix, this.length - suffix.length) !== -1;
-};
-String.prototype.endsWithAny = function (endings) {
- var str = this;
- return endings.some(function (ending) { return str.endsWith(ending); });
-}
var walk = function (dir, done) {
var results = [];
@@ -100,8 +118,10 @@ function scanDir(allFiles, cb) {
var jsBundles = allFiles.filter(function (file) { return file.endsWith(".js.bundle"); });
var cssBundles = allFiles.filter(function (file) { return file.endsWith(".css.bundle"); });
- function getOptions(optionsString) {
- var options = {};
+ function getOptions(fileLines) {
+ var options = clone(defaultOptions);
+ if (fileLines.length === 0) return options;
+ var optionsString = fileLines[0];
if (!optionsString.startsWith('#options ')) return options;
optionsString.substring(9).split(',').forEach(function (option) {
var parts = option.split(':');
@@ -125,7 +145,7 @@ function scanDir(allFiles, cb) {
var bundleName = jsBundle.replace('.bundle', '');
readTextFile(jsBundle, function (data) {
var jsFiles = removeCR(data).split("\n");
- var options = jsFiles.length > 0 ? getOptions(jsFiles[0]) : {};
+ var options = getOptions(jsFiles);
if (options.folder !== undefined) {
options.nobundle = true;
var recursive = options.folder === 'recursive';
@@ -156,7 +176,7 @@ function scanDir(allFiles, cb) {
var bundleName = cssBundle.replace('.bundle', '');
readTextFile(cssBundle, function (data) {
var cssFiles = removeCR(data).split("\n");
- var options = cssFiles.length > 0 ? getOptions(cssFiles[0]) : {};
+ var options = getOptions(cssFiles);
if (options.folder !== undefined) {
options.nobundle = true;
var recursive = options.folder === 'recursive';
@@ -202,6 +202,7 @@ private void RunBundler(string bundleCommandFullName)
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
+ CreateNoWindow = true,
};
process.Exited += (sender, args) =>
@@ -72,8 +72,39 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <Content Include="Content-CommandLineOptions\app.css" />
+ <Content Include="Content-CommandLineOptions\app.js" />
+ <Content Include="Content-CommandLineOptions\css\bootstrap-responsive.css" />
+ <Content Include="Content-CommandLineOptions\css\bootstrap.css" />
+ <Content Include="Content-CommandLineOptions\img\glyphicons-halflings-white.png" />
+ <Content Include="Content-CommandLineOptions\img\glyphicons-halflings.png" />
+ <Content Include="Content-CommandLineOptions\js\backbone.js" />
+ <Content Include="Content-CommandLineOptions\js\base.js" />
+ <Content Include="Content-CommandLineOptions\js\bootstrap.js" />
+ <Content Include="Content-CommandLineOptions\js\ss-validation.js" />
+ <Content Include="Content-CommandLineOptions\js\underscore.js" />
+ <Content Include="Content-CommandLineOptions\options\folder\app.js" />
+ <Content Include="Content-CommandLineOptions\options\folder\something\something.js" />
+ <Content Include="Content-CommandLineOptions\options\folder\thirdparty\thirdparty.js" />
+ <Content Include="Content-CommandLineOptions\options\nobundle\app.js" />
+ <Content Include="Content-CommandLineOptions\options\skipmin\app.js" />
<Content Include="Content\css\bootstrap-responsive.css" />
<Content Include="Content\css\bootstrap.css" />
+ <None Include="Content-CommandLineOptions\app.css.bundle" />
+ <None Include="Content-CommandLineOptions\app.js.bundle" />
+ <None Include="Content-CommandLineOptions\css\default.less" />
+ <None Include="Content-CommandLineOptions\js\app.coffee" />
+ <None Include="Content-CommandLineOptions\options\folder\app.less" />
+ <None Include="Content-CommandLineOptions\options\folder\folder-recursive.css.bundle" />
+ <None Include="Content-CommandLineOptions\options\folder\folder-recursive.js.bundle" />
+ <None Include="Content-CommandLineOptions\options\folder\folder.css.bundle" />
+ <None Include="Content-CommandLineOptions\options\folder\folder.js.bundle" />
+ <None Include="Content-CommandLineOptions\options\nobundle\app.less" />
+ <None Include="Content-CommandLineOptions\options\nobundle\nobundle.css.bundle" />
+ <None Include="Content-CommandLineOptions\options\nobundle\nobundle.js.bundle" />
+ <None Include="Content-CommandLineOptions\options\skipmin\app.less" />
+ <None Include="Content-CommandLineOptions\options\skipmin\skipmin.css.bundle" />
+ <None Include="Content-CommandLineOptions\options\skipmin\skipmin.js.bundle" />
<None Include="Content\app.css.bundle" />
<None Include="Content\app.js.bundle" />
<None Include="Content\css\default.less" />
Oops, something went wrong.

0 comments on commit 9e9cd43

Please sign in to comment.