Example #1
0
    it('should have the correct root for generated path', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', { html: 'app/foo/index.html' });
      grunt.file.mkdir('app/foo');
      grunt.file.copy(path.join(__dirname, 'fixtures/relative_path_parent.html'), 'app/foo/index.html');

      grunt.task.run('useminPrepare');
      grunt.task.start();

      var concat = grunt.config('concat');
      assert.ok(concat);
      assert.ok(concat.generated);
      assert.equal(concat.generated.files.length, 1);
      var files = concat.generated.files[0];

      assert.equal(files.dest, '.tmp/concat/scripts/thisthat.js');
      assert.equal(files.src.length, 2);
      assert.equal(files.src[0], 'app/scripts/this.js');

      var uglify = grunt.config('uglify');
      assert.equal(uglify.generated.files.length, 1);
      files = uglify.generated.files[0];
      assert.equal(files.dest, 'dist/scripts/thisthat.js');
    });
  it('should have configurable flow per target', function () {
    grunt.log.muted = true;
    grunt.config.init();
    grunt.config('useminPrepare', {
      html: 'index.html',
      options: {
        flow: {
          'html': {
            steps: {'js': ['uglifyjs']},
            post: []
          }
        }
      }
    });
    grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
    grunt.task.run('useminPrepare');
    grunt.task.start();

    var uglify = grunt.config('uglify');
    var concat = grunt.config('concat');

    assert.equal(concat, null);
    assert.ok(uglify);
    assert.equal(uglify.generated.files.length, 1);
    var files = uglify.generated.files[0];
    assert.equal(files.dest, 'dist/scripts/plugins.js');

  });
    it('should accept a root directory', function() {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'foo/build/index.html', options: { root: 'foo' }});
      grunt.file.mkdir('foo');
      grunt.file.mkdir('foo/build');
      grunt.file.copy(path.join(__dirname, 'fixtures/absolute.html'), 'foo/build/index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var concat = grunt.config('concat');
      assert.ok(concat);
      assert.ok(concat.generated);
      assert.equal(concat.generated.files.length, 1);
      var files = concat.generated.files[0];

      assert.equal(files.dest, path.normalize('.tmp/concat/scripts/foo.js'));
      assert.equal(files.src.length, 2);
      assert.equal(files.src[0], 'foo/scripts/bar.js');

      var uglify = grunt.config('uglify');
      assert.equal(uglify.generated.files.length, 1);
      files = uglify.generated.files[0];
      assert.equal(files.dest, 'dist/scripts/foo.js');
    });
Example #4
0
	it('should be able to combine a large number of files together', function(done){
		// Split out sample.md into multiple small files
		var sampleFile = fs.readFileSync(path.resolve('./', 'test/sample.md'), {
			encoding: 'utf8'
		}).split("\n");

		var destFiles = [];
		for(var i = 0; i < sampleFile.length; i++){
			fs.writeFileSync(path.resolve('./', 'test/'+i+'.md'), sampleFile[i]);
			destFiles.push(path.resolve('./', 'test/'+i+'.md'));
		}

		var configObj = {};
		configObj[output] = destFiles;
		grunt.config('aglio.test.files', configObj);
		grunt.config('aglio.test.options.separator', grunt.util.linefeed);
		grunt.task.run('aglio');
		grunt.task.start();

		setTimeout(function(){
			fs.exists(output, function(exists){
				assert(exists);
				resetTempFiles(done)
			})
		}, 1000);
	});
Example #5
0
  it('should update the config (HTML)', function () {
    grunt.log.muted = true;
    grunt.config.init();
    grunt.config('useminPrepare', {
      html: 'index.html'
    });
    grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
    grunt.task.run('useminPrepare');
    grunt.task.start();

    var concat = grunt.config('concat');

    assert.ok(concat);
    assert.ok(concat.generated.files);
    assert.equal(concat.generated.files.length, 2);

    assert.equal(concat.generated.files[1].dest, path.normalize('.tmp/concat/scripts/plugins.js'));
    assert.equal(concat.generated.files[1].src.length, 13);
    assert.equal(concat.generated.files[0].dest, path.normalize('.tmp/concat/styles/main.min.css'));
    assert.equal(concat.generated.files[0].src.length, 1);

    var uglify = grunt.config('uglify');

    assert.equal(uglify.generated.files[0].dest, path.normalize('dist/scripts/plugins.js'));
    assert.deepEqual(uglify.generated.files[0].src, [path.normalize('.tmp/concat/scripts/plugins.js')]);
  });
 uninstalled: function(test) {
     var files = _.filter(grunt.config("pkgbuild.my_build.files"), function(f) {
       return !!f.pkgname || !!f.scripts;
     });
     //test package receipts
     var receipts = grunt.config("receipts");
     test.expect(files.length);
     files.forEach(function(f) {
       var file = f.component || f.root;
       var res = new Buffer("");
       var identifier = f.identifier;
       if(!identifier && !!file) {
           identifier =!!f.component ? receipts["component"] : receipts["root"];
       }
       if(!!identifier) {
           try {
               res = child_process.execSync("pkgutil --pkgs / | grep " + identifier);
           } catch(err) {
               //console.log(err.message);
           }
           test.equal(res.toString().trim(), "", "the package " + identifier + " should not be installed");
       }
     });
     
     test.done();
 }
Example #7
0
    versions.forEach(function (version) {
      // .. then create a karma config for it!
      var karmaConfigName = 'angular-' + grunt.config.escape(version);

      if (grunt.option('core') || grunt.option('fast')){
        grunt.config('karma.' + karmaConfigName, {
          options: {
            files: util.testDependencies.unit
              .concat(util.angularFiles(version)
              .concat(util.testFiles.core_unit))
          }
        });
      } else if ( grunt.option('feature') ){
        grunt.config('karma.' + karmaConfigName, {
          options: {
            files: util.testDependencies.unit
              .concat(util.angularFiles(version)
              .concat(util.testFilesFeature(grunt.option('feature')).unit))
          }
        });
      } else {
        grunt.config('karma.' + karmaConfigName, {
          options: {
            files: util.testDependencies.unit
              .concat(util.angularFiles(version)
                .concat(util.testFiles.unit))
          }
        });
      }
    });
Example #8
0
    it('output config for subsequent tasks (requirejs, concat, ..) should be relative to observed file', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'build/index.html'});
      grunt.file.mkdir('build');
      grunt.file.copy(path.join(__dirname, 'fixtures/relative_path.html'), 'build/index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var concat = grunt.config('concat');
      assert.ok(concat);
      assert.ok(concat['build/scripts/foo.js']);
      assert.equal(concat['build/scripts/foo.js'].length, 2);

      var requirejs = grunt.config('requirejs');

      assert.ok(requirejs.default.options.baseUrl);
      assert.equal(requirejs.default.options.baseUrl, 'build/scripts');
      assert.ok(requirejs.default.options.name);
      assert.equal(requirejs.default.options.name, 'main');
      assert.equal(requirejs.default.options.out, 'build/scripts/amd-app.js');

      var uglify = grunt.config('uglify');
      assert.equal(uglify['build/scripts/amd-app.js'], 'build/scripts/amd-app.js');
      assert.equal(uglify['build/scripts/foo.js'], 'build/scripts/foo.js');
    });
  it('should allow use to furnish new steps of the flow', function() {
    var copy = {
        name: 'copy',
        createConfig: function(context,block) {
            var cfg = {};
            var files = {};
            var inFiles = [];
            context.inFiles.forEach(function(file) { inFiles.push(path.join(context.inDir, file));});
            files.dest = path.join(context.outDir, block.dest);
            files.src = inFiles;
            cfg.files = [files];
            return cfg;
          }
      };
    grunt.log.muted = true;
    grunt.config.init();
    grunt.config('useminPrepare', {
      html: 'index.html',
      options: {
        flow: {
            steps: {'js': [copy]},
            post: []
          }
        }
      });
    grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
    grunt.task.run('useminPrepare');
    grunt.task.start();

    var copyCfg = grunt.config('copy');

    assert.ok(copyCfg);
    assert.equal(copyCfg.generated.files[0].dest, path.normalize('dist/scripts/plugins.js'));
  });
Example #10
0
    it('should update all requirejs multitask configs setting name and output', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'index.html'});
      grunt.config('requirejs', {
        task1: {},
        task2: {
          options: {
            baseUrl: 'base'
          }
        }
      });
      grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var requirejs = grunt.config('requirejs');
      assert.ok(requirejs.task1.options.name);
      assert.ok(requirejs.task2.options.name);

      assert.equal(requirejs.task1.options.name, 'main');
      assert.equal(requirejs.task2.options.name, 'main');

      assert.equal(requirejs.task1.options.out, 'scripts/amd-app.js');
      assert.equal(requirejs.task2.options.out, 'scripts/amd-app.js');

      assert.equal(requirejs.task1.options.baseUrl, 'scripts');
      assert.equal(requirejs.task2.options.baseUrl, 'base');

      assert.equal(requirejs.task1.options.mainConfigFile, 'scripts/main.js');
      // assert.equal(requirejs.task2.options.mainConfigFile, 'base');
    });
Example #11
0
    it('should update the config (HTML)', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'index.html'});
      grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var concat = grunt.config('concat');
      assert.ok(concat);
      assert.ok(concat['scripts/plugins.js']);
      assert.equal(concat['scripts/plugins.js'].length, 13);
      assert.ok(concat['styles/main.min.css']);
      assert.equal(concat['styles/main.min.css'].length, 1);

      var requirejs = grunt.config('requirejs');
      assert.ok(requirejs.default.options.baseUrl);
      assert.equal(requirejs.default.options.baseUrl, 'scripts');
      assert.ok(requirejs.default.options.name);
      assert.equal(requirejs.default.options.name, 'main');
      assert.equal(requirejs.default.options.out, 'scripts/amd-app.js');


      var uglify = grunt.config('uglify');
      assert.equal(uglify['scripts/amd-app.js'], 'scripts/amd-app.js');
      assert.equal(uglify['scripts/plugins.js'], 'scripts/plugins.js');
    });
Example #12
0
		topic: function () {
			// Activate the android platform
			grunt.config("platforms.android.active", true);
			console.log("platforms: " + (stringify(grunt.config('platforms'))));
			// Launch the copy task
			grunt.tasks(["clean", "copy"], {
				verbose: true
			}, this.callback)
		},
Example #13
0
 this.options = function() {
   var targetObj = grunt.config([name, target]);
   var args = [{}].concat(grunt.util.toArray(arguments)).concat([
     grunt.config([name, 'options']),
     grunt.util.kindOf(targetObj) === 'object' ? targetObj.options : {}
   ]);
   var options = grunt.util._.extend.apply(null, args);
   grunt.verbose.writeflags(options, 'Options');
   return options;
 };
  it('should update the configs and manifest.json', function () {
    var concat, uglify, cssmin, manifest;
    var target = _.clone(targets.dist, true);
    var src = target.src;
    var dest = target.dest;
    var background = path.join(dest, target.options.background.target || 'background.js');
    var exclude = target.options.background.exclude;

    grunt.file.copy(path.join(__dirname, 'fixtures/manifest.json'), 'app/manifest.json');
    grunt.config.init();
    grunt.config('chromeManifest', {dist: target});
    grunt.task.run('chromeManifest:dist');
    grunt.task.start();

    concat = grunt.config('concat');
    uglify = grunt.config('uglify');
    cssmin = grunt.config('cssmin');
    manifest = grunt.file.readJSON(path.join(src, 'manifest.json'));

    // check concat and uglify list on background scripts.
    _.each(concat.background.src, function (script, i) {
      if (_.indexOf(exclude, script) !== -1) {
        assert.equal(concat.background.src[i], path.join(src, manifest.background.scripts[i]));
      }
    });
    assert.equal(concat.background.dest, background);
    assert.ok(uglify[background]);
    assert.equal(uglify[background], background);

    // check cssmin and uglify list on contents scripts.
    for (var cs = 0, max = manifest.content_scripts.length; cs < max; ++cs) {
      var file, i, maxChild;
      for (i = 0, maxChild = manifest.content_scripts[cs].js.length; i < maxChild; ++i) {
        file = 'scripts/contentscript-' + parseInt(cs, 10) + parseInt(i, 10) + '.js';
        assert.ok(uglify[path.join(dest, file)]);
        assert.equal(uglify[path.join(dest, file)], path.join(src, file));
      }

      for (i = 0, maxChild = manifest.content_scripts[cs].css.length; i < maxChild; ++i) {
        file = 'styles/contentstyle-' + parseInt(cs, 10) + parseInt(i, 10) + '.css';
        assert.ok(cssmin[path.join(dest, file)]);
        assert.equal(cssmin[path.join(dest, file)], path.join(src, file));
      }
    }

    // check updated manifest.json
    manifest = grunt.file.readJSON(path.join(dest, 'manifest.json'));
    assert.ok(manifest);
    assert.equal(manifest.background.scripts[0], target.options.background.target);

    _.each(manifest.background.scripts, function (script) {
      assert.ok(_.indexOf(exclude, script) === -1);
    });

  });
  default_options: function(test) {

      grunt.task.run("connect:serverTest1");
      grunt.task.run("portChecker");

      // The port of our second server should have
      test.equal(grunt.config("connect.serverTest2.options.port"), "3335", "Target port should be modified");
      test.equal(grunt.config("connect.serverTest2.options.url"), "http://localhost:3335/test", "Port on url should be modified");

    test.done();
  }
Example #16
0
    it('should have configurable name for ugligy', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'index.html', options: { 'uglify': 'foo'}});
      grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var uglify = grunt.config('foo');
      assert.equal(uglify['scripts/amd-app.js'], 'scripts/amd-app.js');
      assert.equal(uglify['scripts/plugins.js'], 'scripts/plugins.js');
    });
Example #17
0
  it('should take dest option into consideration', function () {
    grunt.log.muted = true;
    grunt.config.init();
    grunt.config('useminPrepare', {html: 'index.html', options: { 'dest': 'foo'}});
    grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
    grunt.task.run('useminPrepare');
    grunt.task.start();

    var uglify = grunt.config('uglify');
    assert.equal(uglify.generated.files[0].dest, 'foo/scripts/plugins.js');
    assert.deepEqual(uglify.generated.files[0].src, [path.normalize('.tmp/concat/scripts/plugins.js')]);

  });
Example #18
0
    it('should take dest option into consideration', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'index.html', options: { 'dest': 'foo'}});
      grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var uglify = grunt.config('uglify');
      assert.equal(uglify['foo/scripts/amd-app.js'], 'foo/scripts/amd-app.js');
      assert.equal(uglify['foo/scripts/plugins.js'], 'foo/scripts/plugins.js');

    });
Example #19
0
  updateConfig: function() {
    grunt.config('customLaunchers', util.customLaunchers());
    util.createKarmangularConfig()
    util.createSauceConfig();

    if (process.env.TRAVIS) {
      grunt.config('gh-pages.gh-pages.options.user', {
        name: 'grud',
        email: '*****@*****.**'
      });

      grunt.config('gh-pages.gh-pages.options.repo', 'https://' + process.env.GITHUB_NAME + ':' + process.env.GITHUB_PASS + '@github.com/angular-ui/ui-grid.info.git');
    }
  },
 testTaskLocalWasRun: function(test) {
   test.expect(3);
   var expected = {
     cmd: {
       command: 'loadAndRun',
       args: [null, 'testTask:local'],
     }
   };
   var actual = grunt.config('stg.test');
   test.deepEqual(actual, expected, 'stage:<task> should execute <task>:<stage> when it exists.');
   test.equal(grunt.config('stg.stage'), 'local', "stage 'local' should be loaded");
   test.ok(grunt.file.exists('tmp/local'), 'task testTask:local should have run and created file');
   test.done();
 },
Example #21
0
  it('should be able to create multiple output files', function(done){
    // Split out sample.md into multiple small files
    var sampleFile = fs.readFileSync(path.resolve('./', 'test/sample.md'), {
      encoding: 'utf8'
    }).split("\n");

    var destFiles = [];
    for(var i = 0; i < sampleFile.length; i++){
      fs.writeFileSync(path.resolve('./', 'test/'+i+'.md'), sampleFile[i]);
      destFiles.push(path.resolve('./', 'test/'+i+'.md'));
    }

    var configObj = {};
    var configObj2 = {};
    var configObj3 = {};
    var configObj4 = {};
    var configObj5 = {};
    var output2 = output.substr(0, output.length - 4) + '2.html';
    var output3 = output.substr(0, output.length - 4) + '3.html';
    var output4 = output.substr(0, output.length - 4) + '4.html';
    var output5 = output.substr(0, output.length - 4) + '5.html';
    configObj[output2] = path.resolve('./', 'test/sample.md');
    configObj[output] = destFiles;
    configObj2[output2] = path.resolve('./', 'test/sample.md');
    configObj3[output3] = path.resolve('./', 'test/sample.md');
    configObj4[output4] = path.resolve('./', 'test/sample.md');
    configObj5[output5] = path.resolve('./', 'test/sample.md');
    grunt.config('aglio.test.files', configObj);
    grunt.config('aglio.test.options.separator', grunt.util.linefeed);
    grunt.config('aglio.test2.files', configObj2);
    grunt.config('aglio.test2.options.separator', grunt.util.linefeed);
    grunt.config('aglio.test3.files', configObj3);
    grunt.config('aglio.test3.options.separator', grunt.util.linefeed);
    grunt.config('aglio.test4.files', configObj4);
    grunt.config('aglio.test4.options.separator', grunt.util.linefeed);
    grunt.config('aglio.test5.files', configObj5);
    grunt.config('aglio.test5.options.separator', grunt.util.linefeed);
    grunt.task.run('aglio');
    grunt.task.start();

    setTimeout(function(){
      assert(fs.existsSync(output));
      assert(fs.existsSync(output2));
      assert(fs.existsSync(output3));
      assert(fs.existsSync(output4));
      assert(fs.existsSync(output5));
      resetTempFiles(done);
    }, 4000);
  });
Example #22
0
    it('should create a requirejs multitask config setting with name and output if non settings exists', function () {
      grunt.log.muted = true;
      grunt.config.init();
      grunt.config('useminPrepare', {html: 'index.html'});

      grunt.file.copy(path.join(__dirname, 'fixtures/usemin.html'), 'index.html');
      grunt.task.run('useminPrepare');
      grunt.task.start();

      var requirejs = grunt.config('requirejs');
      assert.ok(requirejs.default.options.name);
      assert.equal(requirejs.default.options.name, 'main');
      assert.equal(requirejs.default.options.out, 'scripts/amd-app.js');
      assert.equal(requirejs.default.options.baseUrl, 'scripts');
    });
Example #23
0
  createSauceConfig: function() {
    var launchers = util.customLaunchers();

    var chunkNames = Object.keys(launchers);
    var chunks = [].concat.apply([], chunkNames.map(function (c, i) {
      return i % 3 ? [] : [ chunkNames.slice(i, i + 3) ];
    }));

    // console.log(chunks);
    chunks.forEach(function (c, i) {
      grunt.config('karma.sauce-' + i, {
        background: false,
        singleRun: true,
        // reporters: ['saucelabs', 'coverage'],
        reporters: ['saucelabs'],
        browsers: c
        // preprocessors: {
        //   'src/**/!(*.spec)+(.js)': ['coverage']
        // },
        // coverageReporter: {
        //   type: 'lcov',
        //   dir:  'coverage',
        //   subdir: '.'
        // }
      });
    });

    // console.log('tasks', chunks.map(function(c, i) { return 'karma:sauce-' + i }));

    grunt.config('serialsauce', chunks.map(function(c, i) { return 'karma:sauce-' + i }));
  },
Example #24
0
  build: function(config, fn){
    var files = grunt.file.expand(config.src);
    var styles = config.styles;
    var processedStyles;
    //concat
    var src = files.map(function(filepath) {
      return grunt.file.read(filepath);
    }).join(grunt.util.normalizelf('\n'));
    //process
    var processed = this.process(src, grunt.config('NG_VERSION'), config.strict);
    if (styles) {
      processedStyles = this.addStyle(processed, styles.css, styles.minify);
      processed = processedStyles.js;
      if (config.styles.generateCspCssFile) {
        grunt.file.write(removeSuffix(config.dest) + '-csp.css', CSP_CSS_HEADER + processedStyles.css);
      }
    }
    //write
    grunt.file.write(config.dest, processed);
    grunt.log.ok('File ' + config.dest + ' created.');
    fn();

    function removeSuffix(fileName) {
      return fileName.replace(/\.js$/, '');
    }
  },
  it('should read by specificated path for manifest', function () {
    var concat;
    var target = _.clone(targets.dist, true);
    var background = path.join(target.dest, target.options.background.target || 'background.js');
    
    target.manifest = path.join(__dirname, 'fixtures/manifest.json');
    
    grunt.config.init();
    grunt.config('chromeManifest', {dist: target});
    grunt.task.run('chromeManifest:dist');
    grunt.task.start();
    
    concat = grunt.config('concat');

    assert.equal(concat.background.dest, background);
  });
Example #26
0
  it('should be able to process include directive', function(done){
    var configObj = {};
    configObj[output] = [path.resolve('./', 'test/fixtures/sample-include.md')];
    grunt.config('aglio.test.files', configObj);
    grunt.config('aglio.test.options', {
      includePath: path.join(__dirname, 'fixtures')
    });

    grunt.task.run('aglio');
    grunt.task.start();

    setTimeout(function(){
      assert(fs.existsSync(output));
      resetTempFiles(done);
    }, 1000);
  });
Example #27
0
			topic: function () {
				// Deactivate all platforms
				grunt.config("platforms.android.active", false);
				grunt.config("platforms.ios.active", false);
				grunt.config("platforms.web.active", false);
				console.log("platforms: " + (stringify(grunt.config('platforms'))));
				// this.callback will never be executed
				grunt.tasks(["copy"], {
					verbose: true,
					debug: true
				}, this.callback)
				// Ugly hack to check the result after some time
				setTimeout(function () {
					this.callback()
				}, 2000)
			},
Example #28
0
  it('should allow for additional replacement patterns', function () {
    grunt.file.mkdir('images');
    grunt.file.write('images/image.2132.png', 'foo');
    grunt.log.muted = true;
    grunt.config.init();
    grunt.config('usemin', {
      js: 'misc.js',
      options: {
        assetsDirs: 'images',
        patterns: {
          js: [
            [/referenceToImage = '([^\']+)'/, 'Replacing image']
          ]
        }
      }
    });
    grunt.file.copy(path.join(__dirname, 'fixtures/misc.js'), 'misc.js');
    grunt.task.run('usemin');
    grunt.task.start();

    var changed = grunt.file.read('misc.js');

    // Check replace has performed its duty
    assert.ok(changed.match(/referenceToImage = 'image\.2132\.png'/));
  });
 it("should treat local references", function() {
   grunt.log.muted = true;
   usemin.call(grunt, grunt);
   testHelpers.gruntfile({'usemin-handler': {
     html: 'index.html'}
   });
   grunt.config.init();
   grunt.config('usemin-handler', {html: "index.html"});
   grunt.file.copy(path.join(__dirname,"fixtures/usemin.html"), "index.html");
   
   grunt.task.run('usemin-handler:html');
   
   // Report, etc when all tasks have completed.
   grunt.task.options({
     error: function(e) {
       assert(!e, e); 
     },
     done: function() {
       // Grunt config related to concat should have been changed
       var concat_config = grunt.config('concat');
       // Actually the fixture index.html requires to concat stuff in '/scripts/plugins.js' ...
       // As this references a local file, the concat config should have a key named
       // 'scripts/plugins.js' (i.e. *without* the leading /)
       assert.ok('scripts/plugins.js' in concat_config);
     }
   });
   grunt.task.start();
 });
Example #30
0
    it('should allow for several asset dirs', function () {
        grunt.file.mkdir('build');
        grunt.file.mkdir('foo');
        grunt.file.mkdir('foo/images');
        grunt.file.mkdir('foo/images/misc');
        grunt.file.write('foo/images/test.23012.png', 'foo');
        grunt.file.write('foo/images/bar.23012.png', 'foo');
        grunt.file.write('foo/images/misc/test.2a436.png', 'foo');
        grunt.file.mkdir('bar');
        grunt.file.mkdir('bar/scripts');
        grunt.file.write('bar/scripts/plugins.12345.js', 'bar');
        grunt.file.write('bar/scripts/amd-app.6789.js', 'bar');
        grunt.file.copy(path.join(__dirname, 'fixtures/htmlprocessor_absolute.html'), 'build/index.html');

        grunt.log.muted = true;
        grunt.config.init();
        grunt.config('usemin', {html: 'build/index.html',  options: { assetsDirs: ['foo', 'bar']}});
        grunt.task.run('usemin');
        grunt.task.start();

        var changed = grunt.file.read('build/index.html');

        assert.ok(changed.match(/<img src="\/images\/test\.23012\.png">/));
        assert.ok(changed.match(/<img src="\/\/images\/bar\.23012\.png">/));
        assert.ok(changed.match(/<img src="\/images\/misc\/test\.2a436\.png">/));
        assert.ok(changed.match(/<script src="\/scripts\/plugins\.12345\.js">/));
      });