Ejemplo n.º 1
0
gulp.task('beforeBodyPdf', function () {

  function replaceImgTag(file) {
    // replace img tag
    var filename = path.basename(file.path);
    var imgdir = path.join(cd(), "img", filename.replace(".md", '').replace(/\d+_/, ''));
    file.contents = new Buffer(
      String(file.contents).replace(/\w+\.(png|jpg)/g, imgdir + "/$&")
    );
  }

  return gulp.src('markdown/*.md')
    .pipe(
      tap(function (file) {
        replaceImgTag(file);
      })
    )
    // add YouTube image
    .pipe(replace(/https:\/\/www\.youtube\.com\/watch\?v=(.*)/g, "![](http://i.ytimg.com/vi/$1/0.jpg)\n$&"))

    // QRcode to HTML ver
    .pipe(
      tap(function (file) {
         file.contents = new Buffer(
           String(file.contents) +
             "\n\n![](http://chart.apis.google.com/chart?chs=100x100&cht=qr&chl=http://kasei-san.github.io/njslyr_atmosphere/" + path.basename(file.path).replace(".md", ".html") + ")" +
             " <- このページのHTML版へ!"
         );
      })
    )

    .pipe(gulp.dest('dist/markdown/pdf/'));
});
Ejemplo n.º 2
0
    gulp.task('scripts', function (cb) {
        gulp.src(swiper.jsFiles)
            .pipe(tap(function (file, t){
                addJSIndent (file, t);
            }))
            .pipe(concat(swiper.filename + '.js'))
            .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
            .pipe(gulp.dest(paths.build.scripts))

            .pipe(jshint())
            .pipe(jshint.reporter(stylish));
        gulp.src(swiper.jQueryFiles)
            .pipe(tap(function (file, t){
                addJSIndent (file, t);
            }))
            .pipe(concat(swiper.filename + '.jquery.js'))
            .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
            .pipe(gulp.dest(paths.build.scripts));
        gulp.src(swiper.Framework7Files)
            .pipe(tap(function (file, t){
                addJSIndent (file, t, true);
            }))
            .pipe(concat(swiper.filename + '.framework7.js'))
            .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
            .pipe(gulp.dest(paths.build.scripts))
            .pipe(connect.reload());
        cb();
    });
Ejemplo n.º 3
0
  it('should work with gulp-sourcemaps and autoprefixer with different file.base', (done) => {
    const expectedSourcesBefore = [
      'scss/inheritance.scss',
      'scss/includes/_cats.scss',
      'scss/includes/_dogs.sass',
    ];

    const expectedSourcesAfter = [
      'scss/includes/_cats.scss',
      'scss/includes/_dogs.sass',
      'scss/inheritance.scss',
    ];

    gulp.src(path.join(__dirname, 'scss', 'inheritance.scss'), { base: 'test' })
      .pipe(sourcemaps.init())
      .pipe(sass.sync())
      .pipe(tap((file) => {
        should.exist(file.sourceMap);
        file.sourceMap.sources.should.eql(expectedSourcesBefore);
      }))
      .pipe(postcss([autoprefixer()]))
      .pipe(tap((file) => {
        should.exist(file.sourceMap);
        file.sourceMap.sources.should.eql(expectedSourcesAfter);
      }))
      .on('end', done);
  });
Ejemplo n.º 4
0
gulp.task('css', () => {
	return gulp.src([`${config.css.scssDir}/*.scss`])

		// Init sourcemaps
		.pipe(
			config.isRelease ? gutil.noop() : sourcemaps.init()
		)

		// Sass Compilation
		.pipe(
			sass(
				eyeglass()
			).on('error', sass.logError)
		)

		// PostCSS tasks after Sass compilation
		.pipe(
			postcss([
				flexbugsFixes(),
				autoprefixer({browsers: config.css.browsers}),
			])
		)

		// Compress CSS
		.pipe(
			config.isRelease ? postcss([
				cssnano(),
			]) : gutil.noop()
		)

		// Add a banner
		.pipe(
			config.isRelease ? banner(config.misc.banner) : gutil.noop()
		)

		// Write sourcemaps
		.pipe(
			config.isRelease ? gutil.noop() : sourcemaps.write()
		)

    // Rename dist file based on config
    .pipe(tap(file => {
      if(path.basename(file.path) === 'kickoff.css') {
        file.path = path.join(path.dirname(file.path), config.css.distFile + '.css')
      }
    }))

		// Output file-size
		.pipe(
			config.misc.showFileSize ? tap(file => {
				console.log(`❯❯ CSS ${file.relative}`, filesizegzip(file.contents, true));
			}) : gutil.noop()
		)

		// Write file
		.pipe(gulp.dest(`${config.css.distDir}`));
});
Ejemplo n.º 5
0
gulp.task('compile-js', function () {
	gulp.src(config.applicationDir + '/application.ts', { read: false })
		.pipe(plumber())
		.pipe(tap(function (file) {
			var d = require('domain').create();

			d.on("error", function (err) {
				gutil.log(
					gutil.colors.red("Browserify compile error:"),
					err.message,
					"\n\t",
					gutil.colors.cyan("in file"),
					file.path
				);
			});

			d.run(function () {
				file.contents = browserify({
					basedir: config.applicationDir,
					debug: true
				})
					.add(file.path)
					.plugin(tsify)
					.bundle();
			});
		}))
				.pipe(rename('application.js'))
				.pipe(gulp.dest(config.publicDir))
				.pipe(connect.reload());
});
Ejemplo n.º 6
0
gulp.task('mdtex',function() {

  var texFilter = filter('*.tex')
  var mdFilter = filter('*.md')
  var sub = eqSub({
    defaults: {
      display: { margin: '1pt 5pt', fontSize: '12pt' },
      inline: { margin: '0 1pt 0pt 0pt', fontSize: '12pt' }
    }
  })

  return gulp.src('*.mdtex')
    .pipe(sub)

    .pipe(texFilter)
    .pipe(latex())
    .pipe(pdftocairo({format: 'svg'}))
    .pipe(gulp.dest('docs/images'))
    .pipe(tap(function(file) {
      sub.completeSync(file,function(cb) {
        var img = '<img alt="'+this.alt+'" valign="middle" width="' + this.width*1.8 + '" height="' + this.height*1.8 + '" src="'+giturl(this.path)+'">'
        return this.display ? '<p align="center">'+img+'</p>' : img
      })
    }))
    .pipe(texFilter.restore())

    .pipe(mdFilter)
    .pipe(gulp.dest('./'))
    .pipe(mdFilter.restore())

})
Ejemplo n.º 7
0
gulp.task('default',function(){
	var utils = [];
	gulp.src(['../core.js','../*.js'])
	.pipe(footer(';'))
	.pipe(concat('build.js'))
	.pipe(tap(function(file){
		var contents = String(file.contents);
		var matches = contents.match(/require\(.+\)/g);
		matches.forEach(function(match){
			if(/DOM/.test(match)){ contents = contents.replace(match,'') }
			else if(utils.indexOf(match) < 0){
				utils.push(match);
				var split = match.split(/\'|\"/g)[1];
				contents = contents.replace(
					match, fs.readFileSync('../../'+split+'.js','utf8')
				);
			}else{
				contents = contents.replace(match,'')
			}
		});
		file.contents = new Buffer(contents);
		return file;
	}))
	.pipe(uglify())
	.pipe(gulp.dest('./'))
});
Ejemplo n.º 8
0
gulp.task("manifest:combine", ["manifest:digest"], function(cb) {
  console.log("Started manifest:combine task");
  var stream = gulp.src(DEST+"/manifest*")
    .pipe(gulpJsoncombine("manifest.json", function(data) {

      // Merge the various manifest.json properties together
      // jsoncombine gives us an object with the filenames as
      // the top-level keys
      var merged = {
        files: {},
        assets: {}
      };
      for(var manifest in data) {
        for(var file in data[manifest].files) {
          merged.files[file] = data[manifest].files[file];
        }
        for(var asset in data[manifest].assets) {
          merged.assets[asset] = data[manifest].assets[asset];
        }
      }
      return new Buffer(JSON.stringify(merged));
    }))
    .pipe(gulpMd5())
    .pipe(gulpTap(function(file, t) {
      // Get the generated filename
      var splitPath = file.path.split("/");
      finalManifest = splitPath[splitPath.length - 1];
    }))
    .pipe(gulp.dest(DEST));
  stream.on("end", function() {
    console.log("Completed manifest:combine task");
    cb();
  });
});
Ejemplo n.º 9
0
    mkdirp("dist/sublime", function () {

        gulp.src(['dist/**/*.min.css', 'dist/uikit.min.css'])
            .pipe(concat('sublime_tmp_css.py'))
            .pipe(tap(function(file) {

                var css         = file.contents.toString(),
                    classesList = css.match(/\.(uk-[a-z\d\-]+)/g),
                    classesSet  = {},
                    pystring    = '# copy & paste into sublime plugin code:\n';

                // use object as set (no duplicates)
                classesList.forEach(function(c) {
                    c = c.substr(1); // remove leading dot
                    classesSet[c] = true;
                });

                // convert set back to list
                classesList = Object.keys(classesSet);

                pystring += 'uikit_classes = ' + pythonList(classesList) + '\n';

                fs.writeFile("dist/sublime/tmp_css.py", pystring, done);

            }));
    });
Ejemplo n.º 10
0
 gulp.task(task.meteor, function() {
   var
     filenames = ''
   ;
   return gulp.src(manifest.component)
     .pipe(concatFileNames('empty.txt', concatSettings))
     .pipe(tap(function(file) {
       filenames += file.contents;
     }))
     .on('end', function() {
       gulp.src(manifest.assets)
         .pipe(concatFileNames('empty.txt', concatSettings))
         .pipe(tap(function(file) {
           filenames += file.contents;
         }))
         .on('end', function() {
           // remove trailing slash
           filenames = filenames.replace(regExp.match.trailingComma, '').trim();
           gulp.src(release.templates.meteor.component)
             .pipe(plumber())
             .pipe(flatten())
             .pipe(replace(regExp.match.name, regExp.replace.name))
             .pipe(replace(regExp.match.titleName, regExp.replace.titleName))
             .pipe(replace(regExp.match.version, version))
             .pipe(replace(regExp.match.files, filenames))
             .pipe(rename(release.files.meteor))
             .pipe(gulp.dest(outputDirectory))
           ;
         })
       ;
     })
   ;
 });
Ejemplo n.º 11
0
gulp.task('fluent-dark-to-light', () => (
  gulp.src(`${input}/**/*.svg`)
    .pipe(tap((file) => {
      const dom = fs.readFileSync(file.path, 'utf-8');
      if (detectTheme(dom) === 'light') {
        let newDom = dom;
        const classNames = getClassNames(dom);
        // First handle 'dark-{color}-10' so that they won't be touched without `-10`
        const classNameMap = classNames
          .filter(str => str.match(/dark-\w+-10/g))
          .map(str => ({
            before: str,
            after: str.replace('dark-', 'light-').replace('25', '10'),
          }));
        for (let i = 0; i < classNameMap.length; i += 1) {
          newDom = newDom
            .replace(new RegExp(classNameMap[i].before, 'g'), classNameMap[i].after);
        }
        // Handle the rest of light classes
        newDom = newDom
          .replace(/dark-/g, 'light-')
          .replace(/IconDark/g, 'IconLight');
        file.contents = Buffer.from(recreateStyleBlock(newDom));
      } else {
        console.log('Please put dark theme svgs in input folder.');
      }
    }))
    .pipe(rename((path) => {
      path.basename = path.basename.replace('IconDark', 'IconLight');
    }))
    .pipe(gulp.dest(`${output}/svgs/light`))
));
Ejemplo n.º 12
0
gulp.task('build', function() {
  var dependencies = ["'mm.core'"],
      componentRegex = /core\/components\/([^\/]+)\/main.js/,
      pluginRegex = /addons\/([^\/]+)\/main.js/;

  gulp.src(paths.js)
    .pipe(clipEmptyFiles())
    .pipe(tap(function(file, t) {
      if (componentRegex.test(file.path)) {
        dependencies.push("'mm.core." + file.path.match(componentRegex)[1] + "'");
      } else if (pluginRegex.test(file.path)) {
        dependencies.push("'mm.addons." + file.path.match(pluginRegex)[1] + "'");
      }
    }))

    // Remove comments, remove empty lines, concat and add license.
    .pipe(stripComments())
    .pipe(removeEmptyLines())
    .pipe(concat('mm.bundle.js'))
    .pipe(insert.prepend(license))

    // Add dependencies, this assumes that the mm module is declared on one line.
    .pipe(insert.transform(function(contents) {
      return contents.replace(
        "angular.module('mm', ['ionic'",
        "angular.module('mm', ['ionic', " + dependencies.join(', '));
    }))
    .pipe(gulp.dest('./www/build'));
});
Ejemplo n.º 13
0
gulp.task('build', function(cb) {

  gulp.src(buildConfig.scripts)
    .pipe(tap(function(file, t) {
      addJSIndent(file, t);
    }))
    .pipe(template({ pkg: pkg }))
    .pipe(sourcemaps.init())
    .pipe(concat(buildConfig.filename + '.js'))
    .pipe(header(buildConfig.banner, {
      pkg: pkg,
      date: buildConfig.date
    }))
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    .pipe(gulp.dest(buildConfig.paths.build))
    .pipe(uglify())
    .pipe(header(buildConfig.banner, {
      pkg: pkg,
      date: buildConfig.date
    }))
    .pipe(rename({
      extname: '.min.js'
    }))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(buildConfig.paths.build))
    .pipe(connect.reload())
    .on('end', function() {
      cb();
    });
});
Ejemplo n.º 14
0
gulp.task('js', function() {
    var b = browserify({
        entries: paths.js.entry,
        debug: true
    });

    return gulp.src(paths.js.entry)
        .pipe(plumber())
        .pipe(tap(
            function (file) {
                var d = require('domain').create();
                d.on("error",
                    function (err) {
                        gutil.log(gutil.colors.red("Browserify compile error:"), err.message, "\n\t", gutil.colors.cyan("in file"), file.path);
                        gutil.beep();
                    }
                );

                d.run(function () {
                    file.contents = browserify({
                        entries: [file.path],
                        debug: isDebug
                    }).bundle();
                });
            }
        ))
        .pipe(gulpif(!isDebug, streamify(uglify({
            compress: true
        }))))
        .pipe(rename('bundle.js'))
        .pipe(gulp.dest(paths.js.dest))
        .pipe(reload({stream: true}));
});
Ejemplo n.º 15
0
gulp.task('dist:ui', function() {

  return gulp.src(config.ui.src)
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(replace(config.regex.JSHINT, ''))
    .pipe(replace(config.regex.GLOBAL, ''))
    .pipe(tap(function(file) {
      var relativePath = file.path.match(/availity-angular(.*)/)[1];
      file.relativePath = relativePath;
    }))
    .pipe(header('// Source: <%= file.relativePath %>\n'))
    .pipe(concat(config.ui.name))
    .pipe(header(banner() + '\n'))
    .pipe(sourcemaps.write(config.ui.destMaps))
    .pipe(gulp.dest(config.ui.destDist))
    .pipe(filter('**/*.js'))
    .pipe(uglify({
      mangle: false,
      preserveComments: false,
      compress: false
    }))
    .pipe(header(banner() + '\n'))
    .pipe(rename({ extname: '.min.js' }))
    .pipe(gulpif(config.args.verbose, using({prefix: 'Task [dist:js] using'})))
    .pipe(sourcemaps.write(config.ui.destMaps))
    .pipe(gulp.dest(config.ui.destDist));

});
Ejemplo n.º 16
0
gulp.task('dist:lib', function() {

  var getPkgRegex = function() {
    var pkg = JSON.parse(fs.readFileSync(path.join(config.project.path, 'package.json'), 'utf8'));
    return '$1v' + pkg.version + '$3';
  };

  return gulp.src(config.lib.src)
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(replace(config.regex.JSHINT, ''))
    .pipe(replace(config.regex.GLOBAL, ''))
    .pipe(replace(config.regex.VERSION, getPkgRegex()))
    .pipe(tap(function(file) {
      var relativePath = file.path.match(/availity-angular(.*)/)[1];
      file.relativePath = relativePath;
    }))
    .pipe(header('// Source: <%= file.relativePath %>\n'))
    .pipe(concat(config.lib.name))
    .pipe(header(banner() + '\n'))
    .pipe(sourcemaps.write(config.lib.destMaps))
    .pipe(gulp.dest(config.lib.destDist))
    .pipe(filter('**/*.js'))
    .pipe(uglify({
      mangle: false,
      preserveComments: false,
      compress: false
    }))
    .pipe(header(banner() + '\n'))
    .pipe(rename({ extname: '.min.js' }))
    .pipe(gulpif(config.args.verbose, using({prefix: 'Task [dist:js] using'})))
    .pipe(sourcemaps.write(config.lib.destMaps))
    .pipe(gulp.dest(config.lib.destDist));

});
Ejemplo n.º 17
0
gulp.task('app-js', [], function(cb) {
    return gulp.src(config.app.js.src, {read: false})
        .pipe(tap(function(file) {
            // Replace file contents with browserify's bundle stream.
            file.contents = browserify(file.path, {debug: true}).bundle()
                .on('error', function(err) {
                    gutil.log(gutil.colors.red('Browserify error') + err);
                    gutil.beep();
                    cb();
                });
        }))
        // Transform streaming contents into buffer contents
        // (because gulp-sourcemaps does not support streaming contents).
        .pipe(buffer())
        .pipe(sourcemaps.init())
        .pipe(cached('app-js'))
        .pipe(babel({presets: ['env'], compact: false}))
        .pipe(wrap('(function(angular){\'use strict\';<%= contents %>})(angular);'))
        .pipe(ifElse(isProduction, uglify))
        .pipe(remember('app-js'))
        .pipe(concat(config.app.js.fileName))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(config.app.buildDir))
        .pipe(ifElse(isWatcher, size))
        .pipe(ifElse(isWatcher, livereload));
});
Ejemplo n.º 18
0
gulp.task('compile', function () {
    checkArgv();
    gulp.src(argv.buffer + (argv.buffer.substr(-5, 5) == '.json' ? '' : '*.json')).pipe(tap(function(file, t){
        var assets =  JSON.parse(file.contents.toString());
        compileAssets(assets);
    }));
});
Ejemplo n.º 19
0
		.pipe(tap(function (file, t) {

			var baseName = path.basename(file.path),
				nameParts = baseName.split('.'),
				viewBaseName = _.last(nameParts[0].split('view-')),

				// Grab all templates that aren't root files
				// aka views
				templates = globule.find([
					'templates/**/*.*',
					'!templates/*.*',
					'templates/' + viewBaseName + '.*',
					'!_*'
				])
			;

			gulp.src(config.export_assets + '/assets/css/' + baseName)
				.pipe(bytediff.start())
				.pipe(uncss({
					html: templates || [],
					ignore: config.uncssIgnore || []
				}))
				.pipe(bytediff.stop())
				.pipe(gulp.dest(config.export_assets + '/assets/css'))
				.pipe(tap(function (file) {

					// If this was the last file, end the task
					if(count === numViews) cb(null);
				}))
			;

			count = count + 1;
		}))
Ejemplo n.º 20
0
gulp.task('release:createRelease', false, function(cb) {
    var pkg = helper.readJsonFile('./package.json');
    var v = 'v' + pkg.version;
    var message = pkg.version;
    var ownerRepo = constants.repository.split('/').slice(-2);

    return gulp.src('CHANGELOG.md')
        .pipe(tap(function(file) {
            var body = file.contents.toString();
            body = body.slice(body.indexOf('###'));
            var msg = {
                owner: ownerRepo[0],
                repo: ownerRepo[1],
                tag_name: v,
                name: v + ': version ' + message,
                body: body
            };
            github.releases.createRelease(msg, function(err, res) {
                if (err) {
                    gutil.log(gutil.colors.red('Error: ' + err));
                } else {
                    del('CHANGELOG.md');
                }
            });
        }));
});
Ejemplo n.º 21
0
gulp.task('test', ['clean'], function (done) {
    var files = [],
        galen = function galen (file, callback) {
            spawn('galen', [
                'test',
                file.path,
                '--htmlreport',
                reportsDir + '/' + file.relative.replace(/\.test/, '')
            ], {'stdio' : 'inherit'}).on('close', function (code) {
                callback(code === 0);
            });
        };

    gulp.src([suitesGlob])
        .pipe(tap(function (file) {
            files.push(file);
        }))
        .on('end', function () {
            async.rejectSeries(files, function (file, finished) {
                galen(file, finished);
            }, function (errors) {
               if (errors && errors.length > 0) {
                  done("Galen reported failed tests: " + (errors.map(function(f) {
                     return f.relative;
                  }).join(", ")));
               }
               else {
                  done();
               }
            });
        });
});
Ejemplo n.º 22
0
gulp.task('build:js', function (done) {
    var banner = [
        '/*!',
        ' * WeUI.js v<%= pkg.version %> (<%= pkg.homepage %>)',
        ' * Copyright <%= new Date().getFullYear() %>',
        ' * Licensed under the <%= pkg.license %> license',
        ' */',
        ''].join('\n');
    gulp.src('src/*.js')
        .pipe(tap(function (file) {
            var content = file.contents.toString();
            content = content.replace(/@VERSION/g, pkg.version);
            file.contents = new Buffer(content);
        }))
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(order([
            'weui.js',
            'dialog.js',
            'alert.js',
            'toptips.js',
            '*.js'
        ]))
        .pipe(concat('weui.js'))
        .pipe(header(banner, {pkg: pkg}))
        .pipe(gulp.dest('dist'))
        .pipe(uglify())
        .pipe(rename(function (path) {
            path.basename += '.min';
        }))
        .pipe(gulp.dest('dist'))
        .on('end', done);
});
Ejemplo n.º 23
0
  ['index', 'runtime'].forEach(function (mod) {
    var js = mod + '.js';
    var debugJs = mod + '-debug.js';
    var excludeModules;
    if (mod === 'index') {
      excludeModules = [fullName + '/runtime'];
    }
    combinedStream.append(gulp.src(path.resolve(src, js))
      .pipe(modulex({
        modulex: {
          packages: packages
        },
        genDeps: false,
        excludeModules: excludeModules
      }))
      .pipe(kclean({
        files: [
          {
            src: path.resolve(src, debugJs),
            outputModule: fullName + '/' + mod
          }
        ]
      }))
      .pipe(replace(/@VERSION@/g, packageInfo.version))
      .pipe(wrapper({
        header: header
      }))
        .pipe(tap(function(file) {
            //console.log(111, file);
            var reg = /define\(("[^"]+",\s*\[[^\]]*\]),\s*function[^\{]+{/;
            var contents = file.contents.toString();
            var match = contents.match(reg)[1];
            contents = contents.replace(reg,
                        ';(function() {\n' +

                            'if(window.KISSY){\n ' +
                            'KISSY.add(' + match + ',function(S, require, exports, module){\n' +
                            ' _xt(require, exports, module);\n' +
                            '});\n ' +
                            '} else if (window.define){\n ' +
                            'define(' + match + ', _xt);\n' +
                            '}else{\n' +
                            'throw new Error("Can\'t found any module manager, such like Kissy CMD AMD SeaJS and etc.");\n' +
                            '};\n' +
                            'function _xt(require, exports, module) {')
                        .replace(/}\);$/,
                            '};\n' +
                            '})();'
                        );
            //console.log(contents);
            file.contents = new Buffer(contents);
        }))

      .pipe(gulp.dest(build))
      .pipe(filter(debugJs))
      .pipe(replace(/@DEBUG@/g, ''))
      .pipe(uglify())
      .pipe(rename(js))
      .pipe(gulp.dest(build)));
  });
Ejemplo n.º 24
0
gulp.task('js', function() {
  return gulp.src('./src/js/main.js')
    .pipe(plumber())
    .pipe(tap(function(file) {
      const dom = domain.create();
      dom.on('error', function(err) {
        gutil.log(
          gutil.colors.red('Browserify compile error:'),
          err.message, '\n\t',
          gutil.colors.cyan('in file'), file.path
        );
        gutil.beep();
      });
      dom.run(function() {
        file.contents = browserify({
          entries: [file.path],
          debug: false,
          standalone: 'Planting',
          paths: ['./node_modules/', './src/'],
          transform: [
            [hbsfy, {
              global: true,
              ignore: /\/node_modules\/(?!plantingjs\/)/,
            }],
            [babelify, {
              global: true,
              ignore: /\/node_modules\/(?!plantingjs\/)/,
            }],
          ],
        }).bundle();
      });
    }))
    .pipe(gulp.dest('./dist/js/'));
});
Ejemplo n.º 25
0
function getStream(list, bundles, dist) {
    dist = dist || './dist';
    list = list || [];
    bundles = bundles || [];

    del([dist + '/**/*']);

    var streams = [];

    for (var i = 0; i < list.length; i++) {
        var src = list[i];
        var bundle = bundles[i];
        if (!bundle) bundle = src.replace('.js', '') + '.bundle.js';
        streams.push(browserify(src).bundle().pipe(source(bundle)).pipe(gulp.dest(dist)));
    }

    var minStream = gulp.src(list, {read: false})
        .pipe(tap(function (file) {
            gutil.log('bundling ' + file.path);
            file.contents = browserify(file.path, {debug: false}).bundle();
        }))
        .pipe(buffer())
        .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(uglify())
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(dist));

    streams.push(minStream);

    return es.concat.apply(es, streams);
}
Ejemplo n.º 26
0
gulp.task('lint', function() {

	return gulp.src([config.jshint.src, '!app/src/cache/templates.js'])

		// Execute jshint
		.pipe(jshint(config.jshint.config))

		// Execute jscs
		.pipe(jscs({configPath: './gulp/jscs.jscsrc'}))

		// Instead of modifying gulp-jscs-stylish, add tap to set file.base to empty and remove absUrl from path
		// so paths match and errors get concatonated into the same block
		.pipe(tap(function(file) {
			file.base = '';

			var errorList = file.jscs.errors._errorList || file.jscs.errors;
			var absUrl = process.cwd() + '/';
			return errorList.map(function(error) {
				error.filename = error.filename.replace(absUrl, '');
			});
		}))

		// Combine results from jscs and jshint
		.pipe(stylish.combineWithHintResults())

		// Style output for readability
		.pipe(jshint.reporter('jshint-stylish'))

		// Failures
		.pipe(gulpif(global.buildOnly, jshint.reporter('fail')))

		.pipe(livereload());

});
Ejemplo n.º 27
0
module.exports = function() {

  const sep = path.sep;
  const glob = [
    './src/app/**/directives/**/*.html',
    './src/app/**/states/**/*.html'
  ];

  return gulp
    .src(glob)
    .pipe(tap(file => {
      const dirname = path.dirname(file.relative);
      const names = dirname.split(sep);
      const module = /directives/.test(dirname) ? `${names[0]}.${names[2]}` : names[0];
      // ex: core.map.states.html
      file.path = `${module}.${path.basename(file.relative)}`;
    }))
    .pipe(htmlify({
      customPrefixes: ['ui-']
    }))
    .pipe(gutil.env.dist ? htmlmin({collapseWhitespace: true, removeAttributeQuotes:true}) : gutil.noop())
    .pipe(templateCache('templates.js', {
      root: '',
      module: 'templates',
      standalone: true
    }))
    .pipe(gutil.env.dist ? uglify() : gutil.noop())
    .pipe(gulp.dest('./build/js'))
    .pipe(reload({stream: true}));
};
Ejemplo n.º 28
0
gulp.task('buildBoardJsonDatas', function () {

 var indexBoard  = [];
 var currentFile = "";
 var currentBoardPath = "";

 process.jsonDatasToLoad = [];

 return gulp.src('src/app_data/xml/**/*.xml')
        .pipe(xml2json())
        .pipe(rename({extname: '.json'}))
        .pipe(tap(function (file,t) {
            currentFile = file.relative;
            currentBoardPath = pathUtil.dirname(file.relative);
            console.log(currentBoardPath);
            process.jsonDatasToLoad.push(currentFile);
        }))
        .pipe(jeditor(function(json) {
            indexBoard.push({
            'title':json.board.title,
            'description':json.board.description,
            'boardFile':'/json/'+currentFile,
            'decks':json.board.decks
            });
            return json; // must return JSON object.
        }))
        .pipe(gulp.dest('build/json'))
        .on('end',function(){
            process.jsonDatasToLoad.push(currentBoardPath+'/boards.json');
            jsonfile.writeFileSync('build/json/'+currentBoardPath+'/boards.json', indexBoard);
             console.log(process.jsonDatasToLoad);
             gulp.run('buildAppIndex');
        });
});
Ejemplo n.º 29
0
gulp.task('templates', function templatesTask() {
    var fileName;
    var errorTpl = '<%= error.message %>';

    return gulp.src(paths.dist.tpl)
        .pipe(changed(paths.build.tpl, {extension: '.js'}))
        .pipe(tap(function(file) {
            fileName = file.relative;
        }))
        .pipe(plumber({
            errorHandler: notify.onError({
                message : function() {
                    return errorTpl + '\n\n' + fileName;
                },
                title   : 'Handlebars'
            })
        }))
        .pipe(handlebars())
        .pipe(plumber.stop())
        .pipe(defineModule('amd'))
        .pipe(uglify({
            outSourceMap : false
        }))
        .pipe(gulp.dest(paths.build.tpl))
        .pipe(livereload());
});
Ejemplo n.º 30
0
function gulpBrowserify() {
  return tap(function(file) {
    file.contents = browserify(file.path, {
      debug: true,
      transform: ['partialify', 'hbsfy'],
    }).bundle();
  });
}