コード例 #1
0
    layout_api: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/layout_api/Object_prototype.html');
        var expected = grunt.file.read('test/expected/layout_api/Object_prototype.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'layout_api.');

        test.done();
    }
コード例 #2
0
    custom_renderer: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/custom_renderer/some.html');
        var expected = grunt.file.read('test/expected/custom_renderer/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'custom_renderer.');

        test.done();
    },
コード例 #3
0
  sourceMapLessInline: function(test) {
    test.expect(1);

    var expected = read('test/fixtures/style3.less');
    var sourceMap = grunt.file.readJSON('tmp/sourceMapLessInline.css.map').sourcesContent[0];
    test.equal(grunt.util.normalizelf(sourceMap), grunt.util.normalizelf(expected), 'should put the less file into the generated sourceMap instead of referencing them.');

    test.done();
  },
コード例 #4
0
    default_options: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/default_options/some.html');
        var expected = grunt.file.read('test/expected/default_options/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'default_options.');

        test.done();
    },
コード例 #5
0
    layout: function (test) {
        test.expect(1);

        var actual = grunt.file.read('tmp/layout/some.html');
        var expected = grunt.file.read('test/expected/layout/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'layout.');

        test.done();
    },
コード例 #6
0
    files_array_format: function (test) {
        test.expect(2);

        var actual = grunt.file.read('tmp/files_array_format/some.html');
        var expected = grunt.file.read('test/expected/files_array_format/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'files_array_format some.html.');

        actual = grunt.file.read('tmp/files_array_format/parent.some.html');
        expected = grunt.file.read('test/expected/files_array_format/parent.some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'files_array_format parent.some.html.');

        test.done();
    },
コード例 #7
0
    before_after_compile: function (test) {
        test.expect(2);

        var actual = grunt.file.read('tmp/before_after_compile/some.html');
        var expected = grunt.file.read('test/expected/before_after_compile/some.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'before_after_compile some.html.');

        actual = grunt.file.read('tmp/before_after_compile/some2.html');
        expected = grunt.file.read('test/expected/before_after_compile/some2.html');
        test.equal(grunt.util.normalizelf(actual), grunt.util.normalizelf(expected), 'before_after_compile some2.html.');

        test.done();
    },
コード例 #8
0
    index: function (test) {
        test.expect(2);

        var actual = grunt.file.read('tmp/xtpl/a-xtpl.js', 'utf-8');
        var expected = grunt.util.normalizelf(grunt.file.read('test/expected/a-xtpl.js', 'utf-8'));
        test.equal(actual, expected, 'should build proper compiled a-xtpl file.');

        var actualDep = grunt.file.read('tmp/xtpl/b-xtpl.js', 'utf-8');
        var expectedDep = grunt.util.normalizelf(grunt.file.read('test/expected/b-xtpl.js', 'utf-8'));
        test.equal(actualDep, expectedDep, 'should have proper compiled b-xtpl file.');

        test.done();
    }
コード例 #9
0
  default_options: function(test) {
    test.expect(1);
    var actual = grunt.util.normalizelf( grunt.file.read('tmp/default_options.js') );
    var expected = grunt.util.normalizelf( grunt.file.read('test/expected/default_options.js') );
    test.equal(actual, expected, 'output file doesn\'t match expected result');

    //test.doesNotThrow(
    //  function() {
    //    /*jshint evil:true */
    //    eval(actual);
    //  }
    //);

    test.done();
  },
コード例 #10
0
ファイル: utils.js プロジェクト: 398218995/angular.js
  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$/, '');
    }
  },
コード例 #11
0
AbstractVersioner.prototype.saveVersionsMap = function () {
  if (this.options.post) { return; }
  if (typeof this.options.versionsMapFile === "string") {
    var versionsMapContent;

    // Are we generating a json file or are we using a template file?
    var templateFile = this.options.versionsMapTemplate;
    if (typeof templateFile === "string") {
      if (!grunt.file.exists(templateFile)) {

      }
      var template = grunt.util.normalizelf(grunt.file.read(templateFile, 'utf8'));
      versionsMapContent = grunt.template.process(template, {
        data: {
          files: this.versionsMap
        }
      }).replace(/[\n]{2}/g,"\n");
    } else {
      versionsMapContent = JSON.stringify(this.versionsMap);
    }
    grunt.file.write(this.options.versionsMapFile, versionsMapContent);
  }

  grunt.config.set(this.getAssetsVersioningTaskConfigKey() + '.versionsMap', this.versionsMap);
  //var originalTask = grunt.config(this.getAssetsVersioningTaskConfigKey() + '.isPostVersioningTaskFor');
  //if (typeof originalTask === 'string') {
  //  grunt.config.set(originalTask + '.versionsMap', this.versionsMap);
  //}

  if (typeof this.isPostVersioningTask  === 'string') {
    grunt.config.set(this.isPostVersioningTask + '.versionsMap', this.versionsMap);
  }

  grunt.log.debug("Versions Map: ", this.versionsMap);
};
コード例 #12
0
        }, function (err, result, code) {

            var expected = getNormalizedFile('test/expected/failure_options');
            var actual = grunt.util.normalizelf(result.stdout);
            test.equal(actual, expected);
            test.done();
        });
コード例 #13
0
  strip_banner: function(test) {
    test.expect(10);

    var src = getNormalizedFile('test/fixtures/banner.js');
    test.equal(comment.stripBanner(src), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');
    test.equal(comment.stripBanner(src, {block: true}), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');
    test.equal(comment.stripBanner(src, {block: true, line: true}), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');

    src = getNormalizedFile('test/fixtures/banner2.js');
    test.equal(comment.stripBanner(src), grunt.util.normalizelf('\n/*! SAMPLE\n * BANNER */\n\n// Comment\n\n/* Comment */\n'), 'It should not strip the top banner.');
    test.equal(comment.stripBanner(src, {block: true}), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');
    test.equal(comment.stripBanner(src, {block: true, line: true}), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');

    src = getNormalizedFile('test/fixtures/banner3.js');
    test.equal(comment.stripBanner(src), grunt.util.normalizelf('\n// This is\n// A sample\n// Banner\n\n// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should not strip the top banner.');
    test.equal(comment.stripBanner(src, {block: true}), grunt.util.normalizelf('\n// This is\n// A sample\n// Banner\n\n// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should not strip the top banner.');
    test.equal(comment.stripBanner(src, {line: true}), grunt.util.normalizelf('// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should strip the top banner.');
    test.equal(comment.stripBanner(src, {block: true, line: true}), grunt.util.normalizelf('// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should strip the top banner.');
    test.done();
  },
コード例 #14
0
    var tempglob = function(src) {
      var content;
      return content = grunt.file.expand(src).map(function(path) {
        return {path: path};
      }).map(function(obj) {

        var filecontent = globFiles(obj.path);
        var filename = path.basename(obj.path, '.hbs').replace('helper-', '');
        return '<div class="pl__atom"><h2 class="pl__atom__title">' + filename + '</h2><div class="pl__atom__content">' + filecontent + '</div></div>\n';
      }).join(grunt.util.normalizelf(grunt.util.linefeed));
    };
コード例 #15
0
    var devscripts = function(src) {
      var content;
      return content = grunt.file.expand(src).map(function(path) {
        return {path: path};
      }).map(function(obj) {

        var filename = path.basename(obj.path);
        // var folderpath = src.replace('*.js', '');
        return '<script type="text/javascript" src="/assets/js/' + filename + '"></script>\n';
      }).join(grunt.util.normalizelf(grunt.util.linefeed));
    };
コード例 #16
0
    }, function(err, result,code) {
      // verify the junit directory exists
      var junitDir = path.join('tmp', 'fail.junit');
      var junitFile = path.join(junitDir, 'fail.js.xml');
      var junitContents = grunt.util.normalizelf(grunt.file.read(junitFile));

      test.ok(junitContents.indexOf('<testsuite name="fail.js"') !== -1, 'testsuite element');
      test.ok(junitContents.indexOf('errors="2"') !== -1, 'Two errors detected');
      test.ok(junitContents.indexOf('AssertionError: this value should be truthy') !== -1, 'Assertion');
      test.ok(junitContents.indexOf('fail - failSupertestError') !== -1, 'Failure message');

      test.done();
    });
コード例 #17
0
    }, function(err, result) {
      // stdout message
      test.ok(result.stdout.indexOf('fail.js.out" created') !== -1, 'File creation notice should be displayed.');

      // verify parts of the fail.js.out contents against ours
      var outFile = path.join('tmp', 'fail.js.out');
      var contents = grunt.util.normalizelf(grunt.file.read(outFile));

      test.ok(contents.indexOf('undefinedundefined') === -1, 'No `undefined`s in output from lack of nodeunit.json defaults');
      test.ok(contents.indexOf('2/2 assertions failed') !== -1, 'Two assertions');

      test.done();
    });
コード例 #18
0
Utils.globFiles = function (src, compare_fn) {
  compare_fn = compareFn(compare_fn);
  var content = void 0;
  var index = 0;
  return content = grunt.file.expand(src).map(function (path) {
    index += 1;
    return {
      index: index,
      path: path,
      content: grunt.file.read(path)
    };
  }).sort(compare_fn).map(function (obj) {
    return obj.content;
  }).join(grunt.util.normalizelf(grunt.util.linefeed));
};
コード例 #19
0
ファイル: utils.js プロジェクト: 2bj/angular-doc
 build: function(config, fn){
   var files = grunt.file.expand(config.src);
   var styles = config.styles;
   //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) processed = this.addStyle(processed, styles.css, styles.minify);
   //write
   grunt.file.write(config.dest, processed);
   grunt.log.ok('File ' + config.dest + ' created.');
   fn();
 },
コード例 #20
0
Helpers.cleanupModules = function(src, filepath) {
  /* Normalize line-feeds */
  src = grunt.util.normalizelf(src);

  /* Remove jshint comments */
  src = src.replace(/[\s]*\/\* (jshint|global).*\n/g, '');

  /* Trim */
  src = src.replace(/^\s+|\s+$/g, '');

  /* Indent */
  src = src.split(lf).map(function(line) {
    return '  ' + line;
  }).join(lf);

  return '  // ' + filepath + lf + src;
};
コード例 #21
0
        }, function (err, result, code) {

            var cwd = process.cwd();

            // test cwd inside the function
            var expected_cwd = 'Running "lambda_invoke:package_folder_options" (lambda_invoke) task\n\n\nSuccess!  Message:\n------------------\n' +
              path.join(cwd, 'test/fixtures/package_folder_option') +
              '\n\nDone, without errors.';
              
            var actual_cwd = grunt.util.normalizelf(result.stdout);
            test.equal(actual_cwd, expected_cwd);

            // test back from the function
            test.equal(process.cwd(), cwd);

            test.done();
        });
コード例 #22
0
    }, function(err, result) {
      // stdout message
      test.ok(result.stdout.indexOf('fail.js.tap" created') !== -1, 'File creation notice should be displayed.');

      // verify parts of the fail.js.tap contents against ours
      var tapFile = path.join('tmp', 'fail.js.tap');
      var tapContents = grunt.util.normalizelf(grunt.file.read(tapFile));

      test.ok(tapContents.indexOf('# fail - fail') !== -1, 'First test should fail');
      test.ok(tapContents.indexOf('not ok 1 - this value should be truthy') !== -1, 'First test failure notice');
      test.ok(tapContents.indexOf('# fail - failSupertestError') !== -1, 'Second test should fail');
      test.ok(tapContents.indexOf('not ok 2 - Something arbitrary') !== -1, 'Second test failure message');
      test.ok(tapContents.indexOf('failed 2') !== -1, 'Total failure count');
      test.ok(tapContents.indexOf('2 tests') !== -1, 'Total test count');

      test.done();
    });
コード例 #23
0
function getNormalizedFile(filepath) {
    return grunt.util.normalizelf(grunt.file.read(filepath));
}
コード例 #24
0
var read = function(src) {
  return grunt.util.normalizelf(grunt.file.read(src));
};
コード例 #25
0
function fileExists(filepath) {
	return grunt.file.exists(grunt.util.normalizelf(filepath))
}
コード例 #26
0
ファイル: utils.js プロジェクト: DeinDesign/css
Utils.normalizelf = function (str) {
  return grunt.util.normalizelf(str);
};
コード例 #27
0
function normalizedFileRead(path) {
  return grunt.util.normalizelf(grunt.file.read(path));
}
コード例 #28
0
function compareOutputs(fn1, fn2) {
  return (grunt.util.normalizelf(fn1.toString()) === grunt.util.normalizelf(fn2.toString()));
}
コード例 #29
0
function readFile(path) {
  var content = grunt.util.normalizelf(grunt.file.read(path));
  //the last line is non-deterministic and must be stripped
  content = content.replace(/\}.*\n;/, '');
  return content;
}
コード例 #30
0
ファイル: lsc_test.js プロジェクト: felixSchl/grunt-lsc
function readFile(file) {
  return grunt.util.normalizelf(grunt.file.read(file));  
}