<commit_before>/*
 * Copyright 2015 The Closure Compiler Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Build process for closure-compiler-npm package
 *
 * Since the package doesn't require building, this file runs
 * tests and auto-increments the version number. Auto-increment
 * is used to support continuous delivery.
 *
 * @author Chad Killingsworth (chadkillingsworth@gmail.com)
 */

'use strict';

var gulp = require('gulp');
var gutil = require('gulp-util');
var mocha = require('gulp-mocha');
var git = require('simple-git')(__dirname);
var Semver = require('semver');
var fs = require('fs');
var packageInfo = require('./package.json');
var currentVer = new Semver(packageInfo.version);

gulp.task('test', function() {
  return gulp.src('./test/**.js', {read: false})
      .pipe(mocha());
});
gulp.task('default', ['test']);

/**
 * Check the git diff for package.json to return whether it included
 * a change to the version number.
 * @return {Promise<boolean>}
 */
var didLastCommitChangeVersionNumber = function() {
  return new Promise(function (resolve, reject) {
    git.diff(['HEAD^', 'HEAD', 'package.json'], function(err, data) {
      if (err) {
        return reject(err);
      }

      var versionData = (data || '').match(/^[+-]\s*"version": "[^"]+",$/mg);
      var versionChanged = versionData === null ? false : versionData.length === 2;
      return resolve(versionChanged);
    });
  });
};

/**
 * If the previous commit didn't include a version number change,
 * calculate what the new version should be.
 *
 * @param {boolean} alreadyChanged
 * @returns {Promise<Semver>}
 */
var getNextVersionNumber = function(alreadyChanged) {
  return new Promise(function(resolve, reject) {
    if (alreadyChanged) {
      gutil.log('Previous commit incremented version number. No changes needed.');
      return resolve(currentVer);
    }

    var Compiler = require('./lib/node/closure-compiler');
    var compiler = new Compiler({version: true});
    compiler.run(function(code, data, err) {
      if (code !== 0) {
        return reject(new Error('Non-zero exit code: ' + code));
      }

      var versionNum = (data || '').match(/Version:\sv(.*)$/m);
      if (versionNum.length !== 2) {
        return resolve(new Error('Unable to parse compiler version number'));
      }
      var compilerVer = new Semver(versionNum[1] + '.0.0');

      if (compilerVer.compare(currentVer) > 0) {
        gutil.log('New compiler version detected. Increment major release.');
        return resolve(compilerVer);
      }

      var nextVersion = new Semver(packageInfo.version);
      nextVersion.inc('minor');
      gutil.log('Changes detected. Increment minor release.');
      return resolve(nextVersion);
    });
  });
};

/**
 * Given a semver object, update package.json (if needed) to the
 * new version number. If changed, add and commit package.json.
 *
 * @param {Semver} newVersion
 * @returns {Promise<boolean>}
 */
var updatePackageToNewVersion = function(newVersion) {
  return new Promise(function(resolve, reject) {
    if (currentVer.compare(newVersion) >= 0) {
      return resolve(false);
    }

    packageInfo.version = newVersion.version;
    fs.writeFileSync('./package.json', JSON.stringify(packageInfo, null, 2) + '\n');

    git.add('package.json', function(err, data) {})
        .commit('Increment version number to ' + newVersion.version, function(err, data) {
          gutil.log('New version committed: ' + newVersion.version);
          return resolve(true);
        });
  });
};

/**
 * Task to determine whether a bump in the version number is needed.
 * This task is intended to be called a continuous integration system
 * that will auto-push any changes back to the main repository.
 */
gulp.task('release-if-changed', function(callback) {
  var nodeVersion = new Semver(process.version);
  if (nodeVersion.compare(new Semver('5.0.0')) < 0) {
    return callback();
  }

  didLastCommitChangeVersionNumber()
      .then(getNextVersionNumber)
      .then(updatePackageToNewVersion)
      .catch(function(err) {
        throw err;
      });
});
<commit_msg>Slight wording change for release logging<commit_after>/*
 * Copyright 2015 The Closure Compiler Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Build process for closure-compiler-npm package
 *
 * Since the package doesn't require building, this file runs
 * tests and auto-increments the version number. Auto-increment
 * is used to support continuous delivery.
 *
 * @author Chad Killingsworth (chadkillingsworth@gmail.com)
 */

'use strict';

var gulp = require('gulp');
var gutil = require('gulp-util');
var mocha = require('gulp-mocha');
var git = require('simple-git')(__dirname);
var Semver = require('semver');
var fs = require('fs');
var packageInfo = require('./package.json');
var currentVer = new Semver(packageInfo.version);

gulp.task('test', function() {
  return gulp.src('./test/**.js', {read: false})
      .pipe(mocha());
});
gulp.task('default', ['test']);

/**
 * Check the git diff for package.json to return whether it included
 * a change to the version number.
 * @return {Promise<boolean>}
 */
var didLastCommitChangeVersionNumber = function() {
  return new Promise(function (resolve, reject) {
    git.diff(['HEAD^', 'HEAD', 'package.json'], function(err, data) {
      if (err) {
        return reject(err);
      }

      var versionData = (data || '').match(/^[+-]\s*"version": "[^"]+",$/mg);
      var versionChanged = versionData === null ? false : versionData.length === 2;
      return resolve(versionChanged);
    });
  });
};

/**
 * If the previous commit didn't include a version number change,
 * calculate what the new version should be.
 *
 * @param {boolean} alreadyChanged
 * @returns {Promise<Semver>}
 */
var getNextVersionNumber = function(alreadyChanged) {
  return new Promise(function(resolve, reject) {
    if (alreadyChanged) {
      gutil.log('Most recent commit incremented version number. No changes needed.');
      return resolve(currentVer);
    }

    var Compiler = require('./lib/node/closure-compiler');
    var compiler = new Compiler({version: true});
    compiler.run(function(code, data, err) {
      if (code !== 0) {
        return reject(new Error('Non-zero exit code: ' + code));
      }

      var versionNum = (data || '').match(/Version:\sv(.*)$/m);
      if (versionNum.length !== 2) {
        return resolve(new Error('Unable to parse compiler version number'));
      }
      var compilerVer = new Semver(versionNum[1] + '.0.0');

      if (compilerVer.compare(currentVer) > 0) {
        gutil.log('New compiler version detected. Increment major release.');
        return resolve(compilerVer);
      }

      var nextVersion = new Semver(packageInfo.version);
      nextVersion.inc('minor');
      gutil.log('Changes detected. Increment minor release.');
      return resolve(nextVersion);
    });
  });
};

/**
 * Given a semver object, update package.json (if needed) to the
 * new version number. If changed, add and commit package.json.
 *
 * @param {Semver} newVersion
 * @returns {Promise<boolean>}
 */
var updatePackageToNewVersion = function(newVersion) {
  return new Promise(function(resolve, reject) {
    if (currentVer.compare(newVersion) >= 0) {
      return resolve(false);
    }

    packageInfo.version = newVersion.version;
    fs.writeFileSync('./package.json', JSON.stringify(packageInfo, null, 2) + '\n');

    git.add('package.json', function(err, data) {})
        .commit('Increment version number to ' + newVersion.version, function(err, data) {
          gutil.log('New version committed: ' + newVersion.version);
          return resolve(true);
        });
  });
};

/**
 * Task to determine whether a bump in the version number is needed.
 * This task is intended to be called a continuous integration system
 * that will auto-push any changes back to the main repository.
 */
gulp.task('release-if-changed', function(callback) {
  var nodeVersion = new Semver(process.version);
  if (nodeVersion.compare(new Semver('5.0.0')) < 0) {
    return callback();
  }

  didLastCommitChangeVersionNumber()
      .then(getNextVersionNumber)
      .then(updatePackageToNewVersion)
      .catch(function(err) {
        throw err;
      });
});
<|endoftext|>


<commit_before>"use strict";

const gulp = require("gulp");
const rename = require("gulp-rename");
const ejs = require("gulp-ejs");
const webpack = require("webpack-stream");
const minifyHtml = require("gulp-minify-html");
const rev = require("gulp-rev");
const minifyCSS = require("gulp-minify-css");
const autoprefixer = require("autoprefixer");
const postcss = require("gulp-postcss");
const revReplace = require("gulp-rev-replace");
const shell = require("gulp-shell");

const pjson = require("./package.json");

const minifyHtmlConfig = {
    conditionals: true,
    spare: true,
};

const command = "rm -rf build && tsc -p components --pretty && npm run tslint && sass styles/base.scss > build/base.css && scss-lint styles/*.scss";

gulp.task("build", shell.task(`rm -rf dest && ${command} && gulp html-dev && rm -rf build`));

gulp.task("deploy", shell.task(`${command} && gulp html-dest && rm -rf build`));

gulp.task("css-dev", () => {
    return uglifyCss("base", true);
});

gulp.task("css-dest", () => {
    return uglifyCss("base", false);
});

gulp.task("js-dev", () => {
    return bundleAndUglifyJs("index", true);
});

gulp.task("js-dest", () => {
    return bundleAndUglifyJs("index", false);
});

gulp.task("rev-dev", ["css-dev", "js-dev"], () => {
    return revCssAndJs();
});

gulp.task("rev-dest", ["css-dest", "js-dest"], () => {
    return revCssAndJs();
});

gulp.task("map-dest", ["css-dest", "js-dest"], () => {
    return mapJs();
});

gulp.task("html-dev", ["rev-dev"], () => {
    return bundleAndUglifyHtml("index", true);
});

gulp.task("html-dest", ["rev-dest", "map-dest"], () => {
    return bundleAndUglifyHtml("index", false);
});

function uglifyCss(name, isDevelopment) {
    if (isDevelopment) {
        return gulp.src("build/" + name + ".css")
            .pipe(postcss([autoprefixer({ browsers: ["last 2 versions"] })]))
            .pipe(rename(name + ".css"))
            .pipe(gulp.dest("build/styles/"));
    }
    else {
        return gulp.src("build/" + name + ".css")
            .pipe(postcss([autoprefixer({ browsers: ["last 2 versions"] })]))
            .pipe(minifyCSS())
            .pipe(rename(name + ".min.css"))
            .pipe(gulp.dest("build/styles/"));
    }
}

const webpackexternals = {
    "react": "React",
    "react-dom": "ReactDOM",
    "history": "History",
    "react-router": "ReactRouter",
};

function bundleAndUglifyJs(name, isDevelopment) {
    if (isDevelopment) {
        return gulp.src("build/components/" + name + ".js")
            .pipe(webpack({
                externals: webpackexternals
            }))
            .pipe(rename(name + ".js"))
            .pipe(gulp.dest("build/scripts/"));
    }
    else {
        return gulp.src("build/components/" + name + ".js")
            .pipe(webpack({
                plugins: [
                    new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true })
                ],
                devtool: "source-map",
                output: {
                    filename: name + ".min.js"
                },
                externals: webpackexternals,
            }))
            .pipe(gulp.dest("build/scripts/"));
    }
}

function revCssAndJs() {
    return gulp.src(["build/styles/*.css", "build/scripts/*.js"], { base: "build" })
        .pipe(rev())
        .pipe(gulp.dest("dest"))
        .pipe(rev.manifest())
        .pipe(gulp.dest("build/"));
}

function mapJs() {
    return gulp.src("build/scripts/*.map", { base: "build" })
        .pipe(gulp.dest("dest"));
}

function bundleAndUglifyHtml(name, isDevelopment) {
    const manifest = gulp.src("build/rev-manifest.json");
    const config = {
        dotMin: ".min",
        version: pjson.version,
        environment: "",
        imageServerBaseUrl: "https://img.yorkyao.xyz",
        imageUploaderBaseUrl: "https://upload.yorkyao.xyz",
        apiBaseUrl: "",
    };
    if (isDevelopment) {
        config.dotMin = "";
        config.environment = "dev";
        config.imageServerBaseUrl = "http://localhost:7777";
        config.imageUploaderBaseUrl = "http://localhost:9999";
        config.apiBaseUrl = "http://localhost:9998";

        return gulp.src("templates/" + name + ".ejs")
            .pipe(ejs(config))
            .pipe(rename(name + ".html"))
            .pipe(revReplace({
                manifest: manifest
            }))
            .pipe(gulp.dest("dest"));
    }
    else {
        return gulp.src("templates/" + name + ".ejs")
            .pipe(ejs(config))
            .pipe(minifyHtml(minifyHtmlConfig))
            .pipe(rename(name + ".html"))
            .pipe(revReplace({
                manifest: manifest
            }))
            .pipe(gulp.dest("dest"));
    }
}
<commit_msg>improve gulp file<commit_after>"use strict";

const gulp = require("gulp");
const rename = require("gulp-rename");
const ejs = require("gulp-ejs");
const webpack = require("webpack-stream");
const minifyHtml = require("gulp-minify-html");
const rev = require("gulp-rev");
const minifyCSS = require("gulp-minify-css");
const autoprefixer = require("autoprefixer");
const postcss = require("gulp-postcss");
const revReplace = require("gulp-rev-replace");
const shell = require("gulp-shell");

const pjson = require("./package.json");

const minifyHtmlConfig = {
    conditionals: true,
    spare: true,
};

const command = "rm -rf build && tsc -p components --pretty && npm run tslint && sass styles/base.scss > build/base.css && scss-lint styles/*.scss";

gulp.task("build", shell.task(`rm -rf dest && ${command} && gulp html-dev && rm -rf build`));

gulp.task("deploy", shell.task(`${command} && gulp html-dest && rm -rf build`));

gulp.task("css-dev", () => {
    return uglifyCss(true);
});

gulp.task("css-dest", () => {
    return uglifyCss(false);
});

gulp.task("js-dev", () => {
    return bundleAndUglifyJs(true);
});

gulp.task("js-dest", () => {
    return bundleAndUglifyJs(false);
});

gulp.task("rev-dev", ["css-dev", "js-dev"], () => {
    return revCssAndJs();
});

gulp.task("rev-dest", ["css-dest", "js-dest"], () => {
    return revCssAndJs();
});

gulp.task("map-dest", ["css-dest", "js-dest"], () => {
    return mapJs();
});

gulp.task("html-dev", ["rev-dev"], () => {
    return bundleAndUglifyHtml(true);
});

gulp.task("html-dest", ["rev-dest", "map-dest"], () => {
    return bundleAndUglifyHtml(false);
});

function uglifyCss(isDevelopment) {
    const name = "base";
    if (isDevelopment) {
        return gulp.src("build/" + name + ".css")
            .pipe(postcss([autoprefixer({ browsers: ["last 2 versions"] })]))
            .pipe(rename(name + ".css"))
            .pipe(gulp.dest("build/styles/"));
    }
    else {
        return gulp.src("build/" + name + ".css")
            .pipe(postcss([autoprefixer({ browsers: ["last 2 versions"] })]))
            .pipe(minifyCSS())
            .pipe(rename(name + ".min.css"))
            .pipe(gulp.dest("build/styles/"));
    }
}

const webpackexternals = {
    "react": "React",
    "react-dom": "ReactDOM",
    "history": "History",
    "react-router": "ReactRouter",
};

function bundleAndUglifyJs(isDevelopment) {
    const name = "index";
    if (isDevelopment) {
        return gulp.src("build/components/" + name + ".js")
            .pipe(webpack({
                externals: webpackexternals
            }))
            .pipe(rename(name + ".js"))
            .pipe(gulp.dest("build/scripts/"));
    }
    else {
        return gulp.src("build/components/" + name + ".js")
            .pipe(webpack({
                plugins: [
                    new webpack.webpack.optimize.UglifyJsPlugin({ minimize: true })
                ],
                devtool: "source-map",
                output: {
                    filename: name + ".min.js"
                },
                externals: webpackexternals,
            }))
            .pipe(gulp.dest("build/scripts/"));
    }
}

function revCssAndJs() {
    return gulp.src(["build/styles/*.css", "build/scripts/*.js"], { base: "build" })
        .pipe(rev())
        .pipe(gulp.dest("dest"))
        .pipe(rev.manifest())
        .pipe(gulp.dest("build/"));
}

function mapJs() {
    return gulp.src("build/scripts/*.map", { base: "build" })
        .pipe(gulp.dest("dest"));
}

function bundleAndUglifyHtml(isDevelopment) {
    const name = "index";
    const manifest = gulp.src("build/rev-manifest.json");
    const config = {
        dotMin: ".min",
        version: pjson.version,
        environment: "",
        imageServerBaseUrl: "https://img.yorkyao.xyz",
        imageUploaderBaseUrl: "https://upload.yorkyao.xyz",
        apiBaseUrl: "",
    };
    if (isDevelopment) {
        config.dotMin = "";
        config.environment = "dev";
        config.imageServerBaseUrl = "http://localhost:7777";
        config.imageUploaderBaseUrl = "http://localhost:9999";
        config.apiBaseUrl = "http://localhost:9998";

        return gulp.src("templates/" + name + ".ejs")
            .pipe(ejs(config))
            .pipe(rename(name + ".html"))
            .pipe(revReplace({
                manifest: manifest
            }))
            .pipe(gulp.dest("dest"));
    }
    else {
        return gulp.src("templates/" + name + ".ejs")
            .pipe(ejs(config))
            .pipe(minifyHtml(minifyHtmlConfig))
            .pipe(rename(name + ".html"))
            .pipe(revReplace({
                manifest: manifest
            }))
            .pipe(gulp.dest("dest"));
    }
}
<|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var yargs = require("yargs");

gulp.task('validate', function() {
  if (yargs.argv.tag===undefined) {
    throw "Required argument --tag not found";
  }
});

gulp.task('sass', function () {
  gulp.src('./styles/*.scss')
    .pipe(sass({outputStyle: 'compressed'}))
    .pipe(gulp.dest('./build'));
});

gulp.task('minify', function () {
  gulp.src('./cookieconsent.js')
    .pipe(uglify())
    .pipe(rename('cookieconsent.latest.min.js'))
    .pipe(gulp.dest('./build'))
    .pipe(rename('cookieconsent.'+yargs.argv.tag+'.min.js'))
    .pipe(gulp.dest('./build'));
});

gulp.task('copy-images', function () {
  gulp.src('theme-previews/*.png')
    .pipe(gulp.dest('./build'));
});

gulp.task('build', ['validate', 'sass', 'minify', 'copy-images']);
<commit_msg>removed the requirement for tag<commit_after>var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var yargs = require("yargs");

gulp.task('sass', function () {
  gulp.src('./styles/*.scss')
    .pipe(sass({outputStyle: 'compressed'}))
    .pipe(gulp.dest('./build'));
});

gulp.task('minify', function () {
  var minifyPipe =
    gulp.src('./cookieconsent.js')
    .pipe(uglify())
    .pipe(rename('cookieconsent.latest.min.js'))
    .pipe(gulp.dest('./build'));

  if (yargs.argv.tag!==undefined) {
    minifyPipe
      .pipe(rename('cookieconsent.'+yargs.argv.tag+'.min.js'))
      .pipe(gulp.dest('./build'));
  }
});

gulp.task('copy-images', function () {
  gulp.src('theme-previews/*.png')
    .pipe(gulp.dest('./build'));
});

gulp.task('build', ['sass', 'minify', 'copy-images']);
<|endoftext|>


<commit_before>var gulp = require('gulp')
var shell = require('gulp-shell')
var concat = require('gulp-concat')
var cson = require('gulp-cson')
var sass = require('gulp-sass')

gulp.task('clean', shell.task(['rm -f .fontcustom-manifest.json', 'rm -rf ./build/']))

gulp.task('compile-font', shell.task('fontcustom compile'))

gulp.task('pngs', function () {
  return gulp.src('./scripts/scrape-pngs.js')
    .pipe(shell(['phantomjs  <%= file.path %>']))
    .pipe(gulp.dest('build'))
})

gulp.task('cson-mapillary-mappings', function () {
  return gulp.src('mapillary-mappings/*.cson')
    .pipe(cson())
    .pipe(gulp.dest('build/mapillary-mappings'))
})

gulp.task('cson-signs', function () {
  return gulp.src('dev/*.cson')
    .pipe(cson())
    .pipe(gulp.dest('build/signs'))
})

gulp.task('cson-transformations', function () {
  return gulp.src('stylesheets/transformations.cson')
    .pipe(cson())
    .pipe(gulp.dest('build'))
})

gulp.task('concat-traffico-css', ['compile-font'], function () {
  return gulp.src(['build/stylesheets/traffico.css', 'stylesheets/extend.css'])
    .pipe(concat('traffico.css'))
    .pipe(gulp.dest('build/stylesheets'))
})

gulp.task('gen-overview-css', function () {
  return gulp.src('stylesheets/examples.scss').pipe(sass()).pipe(gulp.dest('build/stylesheets'))
})

gulp.task('gen-overview-scss', function () {
  return gulp.src('stylesheets/examples.scss').pipe(gulp.dest('build/gh-pages'))
})

gulp.task('gen-overview', ['cson-signs', 'cson-transformations'], function () {
  return gulp.src('scripts/generate-overview.js').pipe(shell(['mkdir -p build/gh-pages && node <%= file.path %>']))
})

gulp.task('gen-html-map', ['resolve-transformations'], function () {
  return gulp.src('scripts/generate-html-string-dict.js').pipe(shell(['mkdir -p build/string-maps && node <%= file.path %>']))
})

gulp.task('resolve-transformations', ['cson-signs', 'cson-transformations'], function () {
  return gulp.src('scripts/resolve-transformations.js').pipe(shell(['mkdir -p build/signs-simple && node <%= file.path %>']))
})

gulp.task('generate_gh-pages_config', function () {
  return gulp.src('scripts/generate_gh-pages_config.js').pipe(shell(['mkdir -p build/gh-pages && node <%= file.path %>']))
})

gulp.task('patch-names', ['gen-overview'], function () {
  return gulp.src('scripts/patch-names.js').pipe(shell(['node <%= file.path %>']))
})

gulp.task(
  'build',
  [
    'concat-traffico-css',
    'cson-mapillary-mappings',
    'gen-overview',
    'gen-overview-scss',
    'gen-overview-css',
    'generate_gh-pages_config',
    'gen-html-map'
  ]
)

gulp.task('lint', shell.task('node node_modules/standard/bin/cmd.js gulpfile.js scripts/*.js'))

gulp.task('check-for-duplicate-signs', ['build'], function () {
  return gulp.src('scripts/check-for-duplicate-signs.js').pipe(shell(['node <%= file.path %>']))
})

gulp.task(
  'check',
  [
    'check-for-duplicate-signs',
    'lint'
  ]
)

gulp.task(
  'default',
  ['check']
)
<commit_msg>Combine the tasks for generating the overview-css<commit_after>var gulp = require('gulp')
var shell = require('gulp-shell')
var concat = require('gulp-concat')
var cson = require('gulp-cson')
var sass = require('gulp-sass')

gulp.task('clean', shell.task(['rm -f .fontcustom-manifest.json', 'rm -rf ./build/']))

gulp.task('compile-font', shell.task('fontcustom compile'))

gulp.task('pngs', function () {
  return gulp.src('./scripts/scrape-pngs.js')
    .pipe(shell(['phantomjs  <%= file.path %>']))
    .pipe(gulp.dest('build'))
})

gulp.task('cson-mapillary-mappings', function () {
  return gulp.src('mapillary-mappings/*.cson')
    .pipe(cson())
    .pipe(gulp.dest('build/mapillary-mappings'))
})

gulp.task('cson-signs', function () {
  return gulp.src('dev/*.cson')
    .pipe(cson())
    .pipe(gulp.dest('build/signs'))
})

gulp.task('cson-transformations', function () {
  return gulp.src('stylesheets/transformations.cson')
    .pipe(cson())
    .pipe(gulp.dest('build'))
})

gulp.task('concat-traffico-css', ['compile-font'], function () {
  return gulp.src(['build/stylesheets/traffico.css', 'stylesheets/extend.css'])
    .pipe(concat('traffico.css'))
    .pipe(gulp.dest('build/stylesheets'))
})

gulp.task('gen-overview-css', function () {
  return gulp.src('stylesheets/examples.scss').pipe(gulp.dest('build/gh-pages')).pipe(sass()).pipe(gulp.dest('build/stylesheets'))
})

gulp.task('gen-overview', ['cson-signs', 'cson-transformations'], function () {
  return gulp.src('scripts/generate-overview.js').pipe(shell(['mkdir -p build/gh-pages && node <%= file.path %>']))
})

gulp.task('gen-html-map', ['resolve-transformations'], function () {
  return gulp.src('scripts/generate-html-string-dict.js').pipe(shell(['mkdir -p build/string-maps && node <%= file.path %>']))
})

gulp.task('resolve-transformations', ['cson-signs', 'cson-transformations'], function () {
  return gulp.src('scripts/resolve-transformations.js').pipe(shell(['mkdir -p build/signs-simple && node <%= file.path %>']))
})

gulp.task('generate_gh-pages_config', function () {
  return gulp.src('scripts/generate_gh-pages_config.js').pipe(shell(['mkdir -p build/gh-pages && node <%= file.path %>']))
})

gulp.task('patch-names', ['gen-overview'], function () {
  return gulp.src('scripts/patch-names.js').pipe(shell(['node <%= file.path %>']))
})

gulp.task(
  'build',
  [
    'concat-traffico-css',
    'cson-mapillary-mappings',
    'gen-overview',
    'gen-overview-css',
    'generate_gh-pages_config',
    'gen-html-map'
  ]
)

gulp.task('lint', shell.task('node node_modules/standard/bin/cmd.js gulpfile.js scripts/*.js'))

gulp.task('check-for-duplicate-signs', ['build'], function () {
  return gulp.src('scripts/check-for-duplicate-signs.js').pipe(shell(['node <%= file.path %>']))
})

gulp.task(
  'check',
  [
    'check-for-duplicate-signs',
    'lint'
  ]
)

gulp.task(
  'default',
  ['check']
)
<|endoftext|>


<commit_before>"use strict";

var gulp = require("gulp");
var browserify = require("browserify");
var source = require("vinyl-source-stream");
var buffer = require("vinyl-buffer");
var jshint = require("gulp-jshint");
var mocha = require("gulp-mocha");
var istanbul = require("gulp-istanbul");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");

gulp.task("lint", function() {
  return gulp.src([ "gulpfile.js", "src/**/*.js", "test/**/*.js", "plugins/**/*.js" ])
    .pipe(jshint())
    .pipe(jshint.reporter(require("jshint-stylish")))
    .pipe(jshint.reporter("fail"));
});

gulp.task("test", function() {
  return gulp.src("test/**/*.js")
    .pipe(mocha());
});

gulp.task("cover", function(cb) {
  gulp.src("src/**/*.js")
    .pipe(istanbul())
    .on("finish", function() {
      return gulp.src("test/**/*.js")
        .pipe(mocha())
        .pipe(istanbul.writeReports("coverage"))
        .on("end", cb);
    });
});

gulp.task("build", function() {
  return browserify("./index.js")
    .bundle()
    /* neume.js */
    .pipe(source("neume.js"))
    .pipe(gulp.dest("build"))
    /* neume.min.js */
    .pipe(buffer())
    .pipe(uglify())
    .pipe(rename("neume.min.js"))
    .pipe(gulp.dest("build"));
});

gulp.task("travis", [ "lint", "cover" ]);
gulp.task("default", [ "lint", "cover", "build" ]);
<commit_msg>fix gulp task<commit_after>"use strict";

var gulp = require("gulp");
var browserify = require("browserify");
var source = require("vinyl-source-stream");
var buffer = require("vinyl-buffer");
var jshint = require("gulp-jshint");
var mocha = require("gulp-mocha");
var istanbul = require("gulp-istanbul");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");

gulp.task("lint", function() {
  return gulp.src([ "gulpfile.js", "src/**/*.js", "test/**/*.js", "plugins/**/*.js" ])
    .pipe(jshint())
    .pipe(jshint.reporter(require("jshint-stylish")))
    .pipe(jshint.reporter("fail"));
});

gulp.task("test", function() {
  return gulp.src("test/**/*.js")
    .pipe(mocha());
});

gulp.task("cover", function(cb) {
  require("./test/bootstrap/bootstrap.js");
  gulp.src("src/**/*.js")
    .pipe(istanbul())
    .on("finish", function() {
      return gulp.src("test/**/*.js")
        .pipe(mocha())
        .pipe(istanbul.writeReports("coverage"))
        .on("end", cb);
    });
});

gulp.task("build", function() {
  return browserify("./index.js")
    .bundle()
    /* neume.js */
    .pipe(source("neume.js"))
    .pipe(gulp.dest("build"))
    /* neume.min.js */
    .pipe(buffer())
    .pipe(uglify())
    .pipe(rename("neume.min.js"))
    .pipe(gulp.dest("build"));
});

gulp.task("travis", [ "lint", "cover" ]);
gulp.task("default", [ "lint", "cover", "build" ]);
<|endoftext|>


<commit_before>'use strict';
const gulp = require('gulp');
const babel = require('gulp-babel');
// const concat = require('gulp-concat');
const browserSync = require('browser-sync');
const nodemon = require('gulp-nodemon');
// const uglify = require('gulp-uglify');

const paths = {
  jsSrc: 'src/js/**/*.js',
  jsBuild: 'public//js'
};

gulp.task('default',['browser-sync','javascript','watch']);

gulp.task('browser-sync', ['nodemon'], () => {
	browserSync.init(null, {
		proxy: {
            target: "localhost:80",
            ws: true
        },
        files: ["public/**/*.*"],
        browser: "google chrome",
        port: 1000,
        reloadDelay: 500
	});
});

gulp.task('nodemon', (cb) => {
	var started = false;
	return nodemon({
		script: 'server.js',
        ignore: ["public/**/*.*", '/gulpfile.js', "src/**/*.*"]
	}).on('start',  () =>{
		// to avoid nodemon being started multiple times
		if (!started) {
			cb();
			started = true;
		}
	});
});

gulp.task('javascript',()=>{
    return gulp.src(paths.jsSrc)
        .pipe(babel({
            presets: ['es2015']
        }))
        // .pipe(uglify()) // temporarily disable
        // .pipe(concat('velociti.js'))
        .pipe(gulp.dest(paths.jsBuild));
});

gulp.task('watch', () => {
  gulp.watch(paths.jsSrc, ['javascript']);
});

<commit_msg>Fixing issues with browsync<commit_after>'use strict';
const gulp = require('gulp');
const babel = require('gulp-babel');
// const concat = require('gulp-concat');
const browserSync = require('browser-sync');
const nodemon = require('gulp-nodemon');
// const uglify = require('gulp-uglify');

const paths = {
  jsSrc: './src/js/**/*.js',
  jsBuild: './public//js'
};

gulp.task('default',['browser-sync','javascript','watch']);

gulp.task('browser-sync', ['nodemon'], () => {
	browserSync.init(null, {
        injectChanges: true,
		proxy: {
            target: "localhost:80",
            ws: true
        },
        files: ["./public/**/*.*"],
        browser: "google chrome",
        port: 1000,
        reloadDelay: 500
	});
});

gulp.task('nodemon', (cb) => {
	var started = false;
	return nodemon({
		script: 'server.js',
        ignore: ["public/**/*.*", '/gulpfile.js', "src/**/*.*"]
	}).on('start',  () =>{
		// to avoid nodemon being started multiple times
		if (!started) {
			cb();
			started = true;
		}
	});
});

gulp.task('javascript',()=>{
    console.log("javascript")
    browserSync.reload()
    return gulp.src(paths.jsSrc)
        .pipe(babel({
            presets: ['es2015']
        }))
        // .pipe(uglify()) // temporarily disable
        // .pipe(concat('velociti.js'))
        .pipe(gulp.dest(paths.jsBuild));
});

gulp.task('watch', () => {
  gulp.watch(paths.jsSrc, ['javascript']);
});

<|endoftext|>


<commit_before>'use strict';

// Ensure we are running the correct version of Node
var pkg = require('./package.json');
if (process.version.substr(1) !== pkg.engines.node) {
  console.error('\nYou are using the wrong Node version: ' + process.version);
  console.error('\nTry this:\n  $ n ' + pkg.engines.node + '\n');
  process.exit(1);
}

var fs = require('fs');
var _ = require('lodash');

var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');
var filter = require('gulp-filter');
var jshint = require('gulp-jshint');
var livereload = require('gulp-livereload');
var nodemon = require('gulp-nodemon');

var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var revNapkin = require('gulp-rev-napkin');

var sass = require('gulp-ruby-sass');
var scsslint = require('gulp-scss-lint');
var es = require('event-stream');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var imagemin = require('gulp-imagemin');

var browserify = require('browserify');
var watchify = require('watchify');
var dotenv = require('dotenv');
var source = require('vinyl-source-stream');
var rimraf = require('rimraf');
var glob = require('glob');
var dev = false;

process.stdin.setMaxListeners(0);
process.stdout.setMaxListeners(0);

dotenv.load();
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

gulp.task('default', ['lint', 'clean', 'rev', 'images']);

var vendorBundle = [
  {file:'./bower_components/headroom.js/dist/headroom.js', expose:'headroom.js'},
  {file:'./bower_components/dom-delegate/lib/delegate.js', expose:'dom-delegate'},
  {file:'./bower_components/o-hoverable/main.js', expose:'o-hoverable'},
  {file:'./bower_components/o-date/main.js', expose:'o-date'},
  {file:'./bower_components/topojson/topojson.js', expose:'topojson'},
  'd3'
];

// TODO:
// CDNify urls in js and css

gulp.task('sass', function() {
  var style = dev ? 'expanded' : 'compressed';
  return sass('client/scss/', {
          sourcemap: false,
          loadPath: ['bower_components', '.'],
          precision: 5,
          quiet: dev,
          debugInfo: dev,
          style: style
        }).on('error', function (err) { console.log(err.message); if (!dev) throw err; })
        .pipe(autoprefixer({
          browsers: ['> 5%', 'iOS >= 6', 'IE >= 7', 'FF ESR', 'last 2 versions'],
          cascade: dev,
          remove: true
        }))
        .pipe(gulp.dest('./public/css'));
});

function createBrowserify(entry, bundle, watch) {

  var o = {
    entries: './client/js/' + entry,
    debug: dev
  };

  var b = browserify(o, watch ? watchify.args : undefined);

  if (watch) {
    b = watchify(b);
  }

  var e = _.assign({}, process.env, {_: 'purge'});

  b.transform('debowerify');

  b.external(vendorBundle.map(function (v) {
    if (typeof v === 'string') return v;
    return v.expose;
  }));

  b.transform('envify', e);

// Transforms we might need here
// Browserify-shim for JS libs without commonsJS.
// swigify
// node-csvify
  if (watch) {
    b.on('update', rebundle);
  }

  function rebundle() {
    return b.bundle()
          .on('error', function(evt){
            gutil.log('Browserify Error', evt);
            var errFile = 'var stack = ' + JSON.stringify(evt.stack) + ';' +
            'var err = ' + JSON.stringify(evt) + ';console.error("Browserify Error in ' + entry + ': ' + evt.message + '", stack, err)';
            fs.writeFileSync('./public/js/' + bundle, errFile);
          })
          .pipe(source(bundle))
          .pipe(gulp.dest('./public/js'));
  }

  b.end = function() {
    return rebundle();
  };

  return b;
}

gulp.task('vendor', function(cb) {

  browserify({
    debug: dev
  })
  .transform('debowerify')
  .require(vendorBundle)
  .bundle()
  .on('error', cb)
  .on('end', cb)
  .pipe(source('vendor.js'))
  .pipe(gulp.dest('./public/js'));

});

function getBundles() {
  return glob.sync('**/*.main.js', {cwd: 'client/js', nodir: true}).map(function(filename){
    return {file: filename, bundle: filename.replace('.main.js', '.js')};
  });
}

gulp.task('bundles', function(cb) {

  var waiting = 0;

  function r() {
    waiting--;
    if (!waiting) cb();
  }

  getBundles()
    .map(function(d) {
      waiting++;
      return createBrowserify(d.file, d.bundle, false)
              .transform('stripify');
    })
    .forEach(function(b) {
      b.end()
        .on('error', cb)
        .on('end', r);
    });
});

gulp.task('js', ['bundles', 'vendor']);

gulp.task('rev', ['compress'], function () {
  return gulp.src(['public/css/**/*.css', 'public/js/**/*.js'], {base: 'assets'})
        .pipe(gulp.dest('public'))  // copy original assets to build dir
        .pipe(rev())
        .pipe(revReplace({replaceInExtensions: ['.css']}))
        .pipe(revNapkin({verbose:false}))
        .pipe(gulp.dest('public')) // write rev'd assets to build dir
        .pipe(rev.manifest())
        .pipe(gulp.dest('public')); // write manifest to build dir
});

gulp.task('compress', ['sass', 'js'], function() {
  var css = filter('css/*.css');
  var js = filter('js/**/*.js');
  return gulp.src('public/**')
        .pipe(css)
        .pipe(csso())
        .pipe(css.restore())
        .pipe(js)
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(js.restore())
        .pipe(gulp.dest('public'));
});

gulp.task('clean', function(cb) {
  rimraf.sync('public');
  cb();
});

gulp.task('jshint', function(cb) {
  gulp.src('client/js/**/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .on('error', cb)
    .on('finish', cb);
});

function customFailReporter() {
  return es.map(function(file, cb) {
    var error;

    if (file.scsslint.errors) {
      error = new gutil.PluginError('gulp-scss-lint', {
        message: 'ScssLint failed for: ' + file.relative,
        showStack: false
      });
    }

    cb(error, file);
  });
}

gulp.task('scsslint', function(cb) {
  gulp.src('client/scss/**/*.scss')
    .pipe(scsslint())
    .pipe(customFailReporter())
    .on('error', cb)
    .on('end', cb);
});

gulp.task('lint', ['jshint', 'scsslint']);

gulp.task('images', function(cb){
  return gulp.src('client/images/**/*')
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}]
        }))
        .pipe(gulp.dest('public/images'));
});

gulp.task('dev', function(cb) {
  dev = true;
  cb();
});

gulp.task('watch', ['dev', 'sass', 'vendor', 'images'], function() {

  gulp.watch('./{public,templates}/**/*.*').on('change', livereload.changed);
  gulp.watch('./client/scss/**/*.scss', ['sass']);
  gulp.watch('./client/images/**/*.{svg,png,jpg}', ['images']);

  var bundles = getBundles().map(function (d) {
    return createBrowserify(d.file, d.bundle, true);
  });

  livereload.listen();

  function startServer() {
    nodemon({
      script: 'app.js',
      nodeArgs: ['--harmony'],
      quiet: true,
      delay: 0.1,
      watch: ['server', 'app.js'],
      ext: 'js,json'
    })
    .on('start', function(a) {
      setTimeout(function() {
        livereload.changed(a);
        gutil.log('Serving at ' +
          gutil.colors.underline('http://localhost:' + (process.env.PORT || 3000) + '/')
        );
      }, 1100);
    });
  }

  var waiting = bundles.length;

  function dec() {
    waiting--;
    if (!waiting) startServer();
  }

  bundles.forEach(function(b){
    b.end().on('end', dec);
  });

});
<commit_msg>Speed up watch task.<commit_after>'use strict';

// Ensure we are running the correct version of Node
var pkg = require('./package.json');
if (process.version.substr(1) !== pkg.engines.node) {
  console.error('\nYou are using the wrong Node version: ' + process.version);
  console.error('\nTry this:\n  $ n ' + pkg.engines.node + '\n');
  process.exit(1);
}

var fs = require('fs');
var _ = require('lodash');

var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');
var filter = require('gulp-filter');
var jshint = require('gulp-jshint');
var livereload = require('gulp-livereload');
var nodemon = require('gulp-nodemon');

var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var revNapkin = require('gulp-rev-napkin');

var sass = require('gulp-ruby-sass');
var scsslint = require('gulp-scss-lint');
var es = require('event-stream');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var imagemin = require('gulp-imagemin');

var browserify = require('browserify');
var watchify = require('watchify');
var dotenv = require('dotenv');
var source = require('vinyl-source-stream');
var rimraf = require('rimraf');
var glob = require('glob');
var dev = false;

process.stdin.setMaxListeners(0);
process.stdout.setMaxListeners(0);

dotenv.load();
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

gulp.task('default', ['lint', 'clean', 'rev', 'images']);

var vendorBundle = [
  {file:'./bower_components/headroom.js/dist/headroom.js', expose:'headroom.js'},
  {file:'./bower_components/dom-delegate/lib/delegate.js', expose:'dom-delegate'},
  {file:'./bower_components/o-hoverable/main.js', expose:'o-hoverable'},
  {file:'./bower_components/o-date/main.js', expose:'o-date'},
  {file:'./bower_components/topojson/topojson.js', expose:'topojson'},
  'd3'
];

// TODO:
// CDNify urls in js and css

gulp.task('sass', function() {
  var style = dev ? 'expanded' : 'compressed';
  return sass('client/scss/', {
          sourcemap: false,
          loadPath: ['bower_components', '.'],
          precision: 5,
          quiet: dev,
          debugInfo: dev,
          style: style
        }).on('error', function (err) { console.log(err.message); if (!dev) throw err; })
        .pipe(autoprefixer({
          browsers: ['> 5%', 'iOS >= 6', 'IE >= 7', 'FF ESR', 'last 2 versions'],
          cascade: dev,
          remove: true
        }))
        .pipe(gulp.dest('./public/css'));
});

function createBrowserify(entry, bundle, watch) {

  var o = {
    entries: './client/js/' + entry,
    debug: dev
  };

  var b = browserify(o, watch ? watchify.args : undefined);

  if (watch) {
    b = watchify(b);
  }

  var e = _.assign({}, process.env, {_: 'purge'});

  b.transform('debowerify');

  b.external(vendorBundle.map(function (v) {
    if (typeof v === 'string') return v;
    return v.expose;
  }));

  b.transform('envify', e);

// Transforms we might need here
// Browserify-shim for JS libs without commonsJS.
// swigify
// node-csvify
  if (watch) {
    b.on('update', rebundle);
  }

  function rebundle() {
    return b.bundle()
          .on('error', function(evt){
            gutil.log('Browserify Error', evt);
            var errFile = 'var stack = ' + JSON.stringify(evt.stack) + ';' +
            'var err = ' + JSON.stringify(evt) + ';console.error("Browserify Error in ' + entry + ': ' + evt.message + '", stack, err)';
            fs.writeFileSync('./public/js/' + bundle, errFile);
          })
          .pipe(source(bundle))
          .pipe(gulp.dest('./public/js'));
  }

  b.end = function() {
    return rebundle();
  };

  return b;
}

gulp.task('vendor', function(cb) {

  browserify({
    debug: dev
  })
  .transform('debowerify')
  .require(vendorBundle)
  .bundle()
  .on('error', cb)
  .on('end', cb)
  .pipe(source('vendor.js'))
  .pipe(gulp.dest('./public/js'));

});

function getBundles() {
  return glob.sync('**/*.main.js', {cwd: 'client/js', nodir: true}).map(function(filename){
    return {file: filename, bundle: filename.replace('.main.js', '.js')};
  });
}

gulp.task('bundles', function(cb) {

  var waiting = 0;

  function r() {
    waiting--;
    if (!waiting) cb();
  }

  getBundles()
    .map(function(d) {
      waiting++;
      return createBrowserify(d.file, d.bundle, false)
              .transform('stripify');
    })
    .forEach(function(b) {
      b.end()
        .on('error', cb)
        .on('end', r);
    });
});

gulp.task('js', ['bundles', 'vendor']);

gulp.task('rev', ['compress'], function () {
  return gulp.src(['public/css/**/*.css', 'public/js/**/*.js'], {base: 'assets'})
        .pipe(gulp.dest('public'))  // copy original assets to build dir
        .pipe(rev())
        .pipe(revReplace({replaceInExtensions: ['.css']}))
        .pipe(revNapkin({verbose:false}))
        .pipe(gulp.dest('public')) // write rev'd assets to build dir
        .pipe(rev.manifest())
        .pipe(gulp.dest('public')); // write manifest to build dir
});

gulp.task('compress', ['sass', 'js'], function() {
  var css = filter('css/*.css');
  var js = filter('js/**/*.js');
  return gulp.src('public/**')
        .pipe(css)
        .pipe(csso())
        .pipe(css.restore())
        .pipe(js)
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(js.restore())
        .pipe(gulp.dest('public'));
});

gulp.task('clean', function(cb) {
  rimraf.sync('public');
  cb();
});

gulp.task('jshint', function(cb) {
  gulp.src('client/js/**/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
    .pipe(jshint.reporter('fail'))
    .on('error', cb)
    .on('finish', cb);
});

function customFailReporter() {
  return es.map(function(file, cb) {
    var error;

    if (file.scsslint.errors) {
      error = new gutil.PluginError('gulp-scss-lint', {
        message: 'ScssLint failed for: ' + file.relative,
        showStack: false
      });
    }

    cb(error, file);
  });
}

gulp.task('scsslint', function(cb) {
  gulp.src('client/scss/**/*.scss')
    .pipe(scsslint())
    .pipe(customFailReporter())
    .on('error', cb)
    .on('end', cb);
});

gulp.task('lint', ['jshint', 'scsslint']);

gulp.task('images', function(cb){
  return gulp.src('client/images/**/*')
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}]
        }))
        .pipe(gulp.dest('public/images'));
});

gulp.task('dev', function(cb) {
  dev = true;
  cb();
});

gulp.task('watch', ['dev', 'sass', 'vendor', 'images'], function() {

  var bundles = getBundles().map(function (d) {
    return createBrowserify(d.file, d.bundle, true);
  });

  livereload.listen();

  function startServer() {
    nodemon({
      script: 'app.js',
      nodeArgs: ['--harmony'],
      quiet: true,
      delay: 0.1,
      watch: ['server', 'app.js'],
      ext: 'js,json'
    })
    .on('start', function(a) {
      setTimeout(function() {
        livereload.changed(a);
        gutil.log('Serving at ' +
          gutil.colors.underline('http://localhost:' + (process.env.PORT || 3000) + '/')
        );
      }, 1100);
    });
  }

  var waiting = bundles.length;

  function dec() {
    waiting--;
    if (!waiting) startServer();
  }

  bundles.forEach(function(b){
    b.end().on('end', dec);
  });

  gulp.watch('./{public,templates}/**/*.*').on('change', livereload.changed);
  gulp.watch('./client/scss/**/*.scss', ['sass']);
  gulp.watch('./client/images/**/*.{svg,png,jpg}', ['images']);

});
<|endoftext|>


<commit_before>var assert = require('assert')
  , svgicons2svgfont = require(__dirname + '/../src/index.js')
  , Fs = require('fs')
  , StringDecoder = require('string_decoder').StringDecoder
  , Path = require("path");

// Helpers
function generateFontToFile(options, done, fileSuffix) {
  var codepoint = 0xE001
    , dest = __dirname + '/results/' + options.fontName
      + (fileSuffix || '') + '.svg'
    , stream = svgicons2svgfont(Fs.readdirSync(__dirname + '/fixtures/' + options.fontName)
      .map(function(file) {
        var matches = file.match(/^(?:u([0-9a-f]{4})\-)?(.*).svg$/i);
        return {
          codepoint: (matches[1] ? parseInt(matches[1], 16) : codepoint++),
          name: matches[2],
          stream: Fs.createReadStream(__dirname + '/fixtures/' + options.fontName + '/' + file)
        };
      }), options);
  stream.pipe(Fs.createWriteStream(dest)).on('finish', function() {
    assert.equal(
      Fs.readFileSync(__dirname + '/expected/' + options.fontName
        + (fileSuffix || '') + '.svg',
        {encoding: 'utf8'}),
      Fs.readFileSync(dest,
        {encoding: 'utf8'})
    );
    done();
  });
}

function generateFontToMemory(options, done) {
  var content = ''
    , decoder = new StringDecoder('utf8')
    , codepoint = 0xE001
    , stream = svgicons2svgfont(Fs.readdirSync(__dirname + '/fixtures/' + options.fontName)
      .map(function(file) {
        var matches = file.match(/^(?:u([0-9a-f]{4})\-)?(.*).svg$/i);
        return {
          codepoint: (matches[1] ? parseInt(matches[1], 16) : codepoint++),
          name: matches[2],
          stream: Fs.createReadStream(__dirname + '/fixtures/' + options.fontName + '/' + file)
        };
      }), options);
  stream.on('data', function(chunk) {
    content += decoder.write(chunk);
  });
  stream.on('finish', function() {
    assert.equal(
      Fs.readFileSync(__dirname + '/expected/' + options.fontName + '.svg',
        {encoding: 'utf8'}),
      content
    );
    done();
  });
}

// Tests
describe('Generating fonts to files', function() {

	it("should work for simple SVG", function(done) {
    generateFontToFile({
      fontName: 'originalicons'
    }, done);
	});

	it("should work for simple SVG", function(done) {
    generateFontToFile({
      fontName: 'cleanicons'
    }, done);
	});

	it("should work for codepoint mapped SVG icons", function(done) {
    generateFontToFile({
      fontName: 'prefixedicons'
    }, done);
	});

	it("should work with multipath SVG icons", function(done) {
    generateFontToFile({
      fontName: 'multipathicons'
    }, done);
	});

	it("should work with simple shapes SVG icons", function(done) {
    generateFontToFile({
      fontName: 'shapeicons'
    }, done);
	});

	it("should work with variable height icons", function(done) {
    generateFontToFile({
      fontName: 'variableheighticons'
    }, done);
	});

	it("should work with variable height icons and the normalize option", function(done) {
    generateFontToFile({
      fontName: 'variableheighticons',
      normalize: true
    }, done, 'n');
	});

	it("should not display hidden pathes", function(done) {
    generateFontToFile({
      fontName: 'hiddenpathesicons'
    }, done);
	});

	it("should work with real world icons", function(done) {
    generateFontToFile({
      fontName: 'realicons'
    }, done);
	});

});

describe('Generating fonts to memory', function() {

  it("should work for simple SVG", function(done) {
    generateFontToMemory({
      fontName: 'originalicons'
    }, done);
  });

  it("should work for simple SVG", function(done) {
    generateFontToMemory({
      fontName: 'cleanicons'
    }, done);
  });

  it("should work for codepoint mapped SVG icons", function(done) {
    generateFontToMemory({
      fontName: 'prefixedicons'
    }, done);
  });

  it("should work with multipath SVG icons", function(done) {
    generateFontToMemory({
      fontName: 'multipathicons'
    }, done);
  });

  it("should work with simple shapes SVG icons", function(done) {
    generateFontToMemory({
      fontName: 'shapeicons'
    }, done);
  });

});

describe('Using options', function() {

  it("should work with fixedWidth option set to true", function(done) {
    generateFontToFile({
      fontName: 'originalicons',
      fixedWidth: true
    }, done, '2');
  });

  it("should work with custom fontHeight option", function(done) {
    generateFontToFile({
      fontName: 'originalicons',
      fontHeight: 800
    }, done, '3');
  });

  it("should work with custom descent option", function(done) {
    generateFontToFile({
      fontName: 'originalicons',
      descent: -200
    }, done, '4');
  });

});

describe('Testing CLI', function() {

  it("should work for simple SVG", function(done) {
    (require('child_process').exec)(
      'node '+__dirname+'../bin/svgicons2svgfont.js '
      + __dirname + '/expected/originalicons.svg '
      + __dirname + '/results/originalicons.svg',
      function() {
        assert.equal(
          Fs.readFileSync(__dirname + '/expected/originalicons.svg',
            {encoding: 'utf8'}),
          Fs.readFileSync(__dirname + '/results/originalicons.svg',
            {encoding: 'utf8'})
        );
        done();
      }
    );
  });

});

describe('Providing bad glyphs', function() {

	it("should fail when not providing glyph name", function() {
	  var hadError = false;
    try {
      svgicons2svgfont([{
	      stream: Fs.createReadStream('/dev/null'),
	      codepoint: 0xE001
      }]);
    } catch(err) {
	    assert.equal(err instanceof Error, true);
	    assert.equal(err.message, 'Please provide a name for the glyph at index 0');
	    hadError = true;
    }
    assert.equal(hadError, true);
	});

	it("should fail when not providing codepoints", function() {
	  var hadError = false;
    try {
      svgicons2svgfont([{
	      stream: Fs.createReadStream('/dev/null'),
	      name: 'test'
      }]);
    } catch(err) {
	    assert.equal(err instanceof Error, true);
	    assert.equal(err.message, 'Please provide a codepoint for the glyph "test"');
	    hadError = true;
    }
    assert.equal(hadError, true);
	});

});
<commit_msg>More coverage<commit_after>var assert = require('assert')
  , svgicons2svgfont = require(__dirname + '/../src/index.js')
  , Fs = require('fs')
  , StringDecoder = require('string_decoder').StringDecoder
  , Path = require("path");

// Helpers
function generateFontToFile(options, done, fileSuffix) {
  var codepoint = 0xE001
    , dest = __dirname + '/results/' + options.fontName
      + (fileSuffix || '') + '.svg'
    , stream = svgicons2svgfont(Fs.readdirSync(__dirname + '/fixtures/' + options.fontName)
      .map(function(file) {
        var matches = file.match(/^(?:u([0-9a-f]{4})\-)?(.*).svg$/i);
        return {
          codepoint: (matches[1] ? parseInt(matches[1], 16) : codepoint++),
          name: matches[2],
          stream: Fs.createReadStream(__dirname + '/fixtures/' + options.fontName + '/' + file)
        };
      }), options);
  stream.pipe(Fs.createWriteStream(dest)).on('finish', function() {
    assert.equal(
      Fs.readFileSync(__dirname + '/expected/' + options.fontName
        + (fileSuffix || '') + '.svg',
        {encoding: 'utf8'}),
      Fs.readFileSync(dest,
        {encoding: 'utf8'})
    );
    done();
  });
}

function generateFontToMemory(options, done) {
  var content = ''
    , decoder = new StringDecoder('utf8')
    , codepoint = 0xE001
    , stream = svgicons2svgfont(Fs.readdirSync(__dirname + '/fixtures/' + options.fontName)
      .map(function(file) {
        var matches = file.match(/^(?:u([0-9a-f]{4})\-)?(.*).svg$/i);
        return {
          codepoint: (matches[1] ? parseInt(matches[1], 16) : codepoint++),
          name: matches[2],
          stream: Fs.createReadStream(__dirname + '/fixtures/' + options.fontName + '/' + file)
        };
      }), options);
  stream.on('data', function(chunk) {
    content += decoder.write(chunk);
  });
  stream.on('finish', function() {
    assert.equal(
      Fs.readFileSync(__dirname + '/expected/' + options.fontName + '.svg',
        {encoding: 'utf8'}),
      content
    );
    done();
  });
}

// Tests
describe('Generating fonts to files', function() {

	it("should work for simple SVG", function(done) {
    generateFontToFile({
      fontName: 'originalicons'
    }, done);
	});

	it("should work for simple SVG", function(done) {
    generateFontToFile({
      fontName: 'cleanicons'
    }, done);
	});

	it("should work for codepoint mapped SVG icons", function(done) {
    generateFontToFile({
      fontName: 'prefixedicons'
    }, done);
	});

	it("should work with multipath SVG icons", function(done) {
    generateFontToFile({
      fontName: 'multipathicons'
    }, done);
	});

	it("should work with simple shapes SVG icons", function(done) {
    generateFontToFile({
      fontName: 'shapeicons'
    }, done);
	});

	it("should work with variable height icons", function(done) {
    generateFontToFile({
      fontName: 'variableheighticons'
    }, done);
	});

	it("should work with variable height icons and the normalize option", function(done) {
    generateFontToFile({
      fontName: 'variableheighticons',
      normalize: true
    }, done, 'n');
	});

	it("should not display hidden pathes", function(done) {
    generateFontToFile({
      fontName: 'hiddenpathesicons'
    }, done);
	});

	it("should work with real world icons", function(done) {
    generateFontToFile({
      fontName: 'realicons'
    }, done);
	});

});

describe('Generating fonts to memory', function() {

  it("should work for simple SVG", function(done) {
    generateFontToMemory({
      fontName: 'originalicons'
    }, done);
  });

  it("should work for simple SVG", function(done) {
    generateFontToMemory({
      fontName: 'cleanicons'
    }, done);
  });

  it("should work for codepoint mapped SVG icons", function(done) {
    generateFontToMemory({
      fontName: 'prefixedicons'
    }, done);
  });

  it("should work with multipath SVG icons", function(done) {
    generateFontToMemory({
      fontName: 'multipathicons'
    }, done);
  });

  it("should work with simple shapes SVG icons", function(done) {
    generateFontToMemory({
      fontName: 'shapeicons'
    }, done);
  });

});

describe('Using options', function() {

  it("should work with fixedWidth option set to true", function(done) {
    generateFontToFile({
      fontName: 'originalicons',
      fixedWidth: true
    }, done, '2');
  });

  it("should work with custom fontHeight option", function(done) {
    generateFontToFile({
      fontName: 'originalicons',
      fontHeight: 800
    }, done, '3');
  });

  it("should work with custom descent option", function(done) {
    generateFontToFile({
      fontName: 'originalicons',
      descent: -200
    }, done, '4');
  });

});

describe('Testing CLI', function() {

  it("should work for simple SVG", function(done) {
    (require('child_process').exec)(
      'node '+__dirname+'../bin/svgicons2svgfont.js '
      + __dirname + '/expected/originalicons.svg '
      + __dirname + '/results/originalicons.svg',
      function() {
        assert.equal(
          Fs.readFileSync(__dirname + '/expected/originalicons.svg',
            {encoding: 'utf8'}),
          Fs.readFileSync(__dirname + '/results/originalicons.svg',
            {encoding: 'utf8'})
        );
        done();
      }
    );
  });

});

describe('Providing bad glyphs', function() {

	it("should fail when not providing glyph name", function() {
	  var hadError = false;
    try {
      svgicons2svgfont([{
	      stream: Fs.createReadStream('/dev/null'),
	      codepoint: 0xE001
      }]);
    } catch(err) {
	    assert.equal(err instanceof Error, true);
	    assert.equal(err.message, 'Please provide a name for the glyph at index 0');
	    hadError = true;
    }
    assert.equal(hadError, true);
	});

	it("should fail when not providing codepoints", function() {
	  var hadError = false;
    try {
      svgicons2svgfont([{
	      stream: Fs.createReadStream('/dev/null'),
	      name: 'test'
      }]);
    } catch(err) {
	    assert.equal(err instanceof Error, true);
	    assert.equal(err.message, 'Please provide a codepoint for the glyph "test"');
	    hadError = true;
    }
    assert.equal(hadError, true);
	});

	it("should fail when providing the same codepoint twice", function() {
	  var hadError = false;
    try {
      svgicons2svgfont([{
	      stream: Fs.createReadStream('/dev/null'),
	      name: 'test',
	      codepoint: 0xE001
      },{
	      stream: Fs.createReadStream('/dev/null'),
	      name: 'test2',
	      codepoint: 0xE001
      }]);
    } catch(err) {
	    assert.equal(err instanceof Error, true);
	    assert.equal(err.message, 'The glyph "test" codepoint seems to be used already elsewhere.');
	    hadError = true;
    }
    assert.equal(hadError, true);
	});

	it("should fail when providing the same name twice", function() {
	  var hadError = false;
    try {
      svgicons2svgfont([{
	      stream: Fs.createReadStream('/dev/null'),
	      name: 'test',
	      codepoint: 0xE001
      },{
	      stream: Fs.createReadStream('/dev/null'),
	      name: 'test',
	      codepoint: 0xE002
      }]);
    } catch(err) {
	    assert.equal(err instanceof Error, true);
	    assert.equal(err.message, 'The glyph name "test" must be unique.');
	    hadError = true;
    }
    assert.equal(hadError, true);
	});

});
<|endoftext|>


<commit_before>'use strict';

var SERVER = {
        HOST: '127.0.0.1',
        PORT: 8080
    },
    PATH = {
        BUILD: './',
        SOURCE: './src/'
    };

var gulp = require('gulp'),
    concat = require('gulp-concat'),
    del = require('del'),
    imagemin = require('gulp-imagemin'),
    jshint = require('gulp-jshint'),
    minifyCSS = require('gulp-minify-css'),
    minifyHTML = require('gulp-minify-html'),
    minifyJSON = require('gulp-jsonminify'),
    prochtml = require('gulp-processhtml'),
    replace = require('gulp-replace'),
    requirejs = require('requirejs'),
    runSequence = require('run-sequence'),
    size = require('gulp-size'),
    stylish = require('jshint-stylish'),
    webserver = require('gulp-webserver');

gulp.task('lint', function() {
    return gulp.src(PATH.SOURCE + 'scripts/**/*.js')
        .pipe(jshint({
            'bitwise': true,
            'camelcase': true,
            'curly': true,
            'eqeqeq': true,
            'forin': true,
            'immed': true,
            'indent': 4,
            'latedef': true,
            'newcap': true,
            'noarg': true,
            'nonbsp': true,
            'nonew': true,
            'quotmark': 'single',
            'strict': true,
            'trailing': true,
            'undef': true,
            'unused': true,

            'esnext': true,
            'smarttabs': true,
            'sub': true,

            'browser': true,
            'devel': true,
            'node': true,

            'globals': {
                'CONFIG': true,
                'define': true
            }
        }))
        .pipe(jshint.reporter(stylish))
        .pipe(jshint.reporter('fail'));
});

gulp.task('optimize-scripts', function() {
    requirejs.optimize({
        baseUrl: PATH.SOURCE + 'scripts/',
        out: PATH.BUILD + 'scripts/site.min.js',
        mainConfigFile: PATH.SOURCE + 'scripts/main.js',
        include: ['../vendor/requirejs/require.min.js', 'main'],
        insertRequire: ['main'],
        wrap: true,
        optimize: 'uglify2',
        preserveLicenseComments: false
    }, function() {
        return 0;
    }, function(err) {
        console.log(err);
        return 1;
    });
});

gulp.task('optimize-styles', function() {
    return gulp.src([
            PATH.SOURCE + 'vendor/normalize-css/normalize.css',
            PATH.SOURCE + 'vendor/ngDialog/css/ngDialog.min.css',
            PATH.SOURCE + 'fonts/**/*.css',
            PATH.SOURCE + 'styles/**/*.css'
        ])
        .pipe(concat('site.min.css'))
        .pipe(minifyCSS({ keepSpecialComments: 0 }))
        .pipe(gulp.dest(PATH.BUILD + 'styles/'));
});

gulp.task('optimize-html', function() {
    gulp.src(PATH.SOURCE + 'index.html')
        .pipe(prochtml('index.html'))
        .pipe(minifyHTML())
        .pipe(gulp.dest(PATH.BUILD));

    gulp.src(PATH.SOURCE + 'partials/**/*.html')
        .pipe(minifyHTML())
        .pipe(gulp.dest(PATH.BUILD + 'partials/'));
});

gulp.task('optimize-json', function() {
    return gulp.src(PATH.SOURCE + 'data/**/*.json')
        .pipe(minifyJSON())
        .pipe(replace(/^(\)]}',)(?=\[{".+":.+)/, '$1\n'))
        .pipe(gulp.dest(PATH.BUILD + 'data/'));
});

gulp.task('optimize-images', function() {
    return gulp.src(PATH.SOURCE + 'media/images/**/*')
        .pipe(imagemin())
        .pipe(gulp.dest(PATH.BUILD + 'media/images/'));
});

gulp.task('copy', function() {
    gulp.src([
            PATH.SOURCE + 'fonts/fontello/font/*.eot',
            PATH.SOURCE + 'fonts/fontello/font/*.svg',
            PATH.SOURCE + 'fonts/fontello/font/*.ttf',
            PATH.SOURCE + 'fonts/fontello/font/*.woff',
            PATH.SOURCE + 'fonts/lato/font/*.woff'
        ])
        .pipe(gulp.dest(PATH.BUILD + 'font/'));
});

gulp.task('concat-header-scripts', function() {
    return gulp.src([
            PATH.SOURCE + 'tasks/license.js',
            PATH.BUILD + 'scripts/site.min.js'
        ])
        .pipe(concat('site.min.js'))
        .pipe(gulp.dest(PATH.BUILD + 'scripts/'));
});

gulp.task('concat-header-styles', function() {
    return gulp.src([
            PATH.SOURCE + 'tasks/license.css',
            PATH.BUILD + 'styles/site.min.css'
        ])
        .pipe(concat('site.min.css'))
        .pipe(gulp.dest(PATH.BUILD + 'styles/'));
});

gulp.task('clean', function(done) {
    del([
        PATH.BUILD + 'index.html',
        PATH.BUILD + 'font/',
        PATH.BUILD + 'media/',
        PATH.BUILD + 'partials/',
        PATH.BUILD + 'scripts/',
        PATH.BUILD + 'styles/',
    ], done);
});

gulp.task('post-build-scripts', function() {
    var date = new Date();

    return gulp.src(PATH.BUILD + 'scripts/site.min.js')
        .pipe(replace(/(\/\*!)/, '// scripts.min.js build: ' + date + '\n$1'))
        .pipe(gulp.dest(PATH.BUILD + 'scripts/'));
});

gulp.task('post-build-styles', function() {
    var date = new Date();

    return gulp.src(PATH.BUILD + 'styles/site.min.css')
        .pipe(replace(/(\/\*!)/, '/* site.min.js build: ' + date + ' */\n$1'))
        .pipe(gulp.dest(PATH.BUILD + 'styles/'));
});

gulp.task('size', function() {
    return gulp.src([
            PATH.BUILD + 'index.html',
            PATH.BUILD + 'fonts/**/*',
            PATH.BUILD + 'media/**/*',
            PATH.BUILD + 'partial/**/*',
            PATH.BUILD + 'scripts/**/*',
            PATH.BUILD + 'styles/**/*',
        ])
        .pipe(size({
            gzip: true,
            title: 'build -->'
        }));
});

gulp.task('server-dev', function() {
    gulp.src(PATH.SOURCE)
        .pipe(webserver({
            host: SERVER.HOST,
            port: SERVER.PORT,
            livereload: true
        }));
});

gulp.task('server', function() {
    gulp.src(PATH.BUILD)
        .pipe(webserver({
            host: SERVER.HOST,
            port: SERVER.PORT
        }));
});

gulp.task('build', function() {
    runSequence(
        ['clean', 'lint'],
        ['optimize-styles', 'optimize-scripts', 'optimize-html', 'optimize-json', 'copy'],
        'concat-header-styles',
        'concat-header-scripts',
        ['post-build-styles', 'post-build-scripts'],
        ['size', 'server']
    );
});
<commit_msg>Updated paths in gulp optimize-* tasks.<commit_after>'use strict';

var SERVER = {
        HOST: '127.0.0.1',
        PORT: 8080
    },
    PATH = {
        BUILD: './',
        SOURCE: './src/'
    };

var gulp = require('gulp'),
    concat = require('gulp-concat'),
    del = require('del'),
    imagemin = require('gulp-imagemin'),
    jshint = require('gulp-jshint'),
    minifyCSS = require('gulp-minify-css'),
    minifyHTML = require('gulp-minify-html'),
    minifyJSON = require('gulp-jsonminify'),
    prochtml = require('gulp-processhtml'),
    replace = require('gulp-replace'),
    requirejs = require('requirejs'),
    runSequence = require('run-sequence'),
    size = require('gulp-size'),
    stylish = require('jshint-stylish'),
    webserver = require('gulp-webserver');

gulp.task('lint', function() {
    return gulp.src(PATH.SOURCE + 'scripts/**/*.js')
        .pipe(jshint({
            'bitwise': true,
            'camelcase': true,
            'curly': true,
            'eqeqeq': true,
            'forin': true,
            'immed': true,
            'indent': 4,
            'latedef': true,
            'newcap': true,
            'noarg': true,
            'nonbsp': true,
            'nonew': true,
            'quotmark': 'single',
            'strict': true,
            'trailing': true,
            'undef': true,
            'unused': true,

            'esnext': true,
            'smarttabs': true,
            'sub': true,

            'browser': true,
            'devel': true,
            'node': true,

            'globals': {
                'CONFIG': true,
                'define': true
            }
        }))
        .pipe(jshint.reporter(stylish))
        .pipe(jshint.reporter('fail'));
});

gulp.task('optimize-scripts', function() {
    requirejs.optimize({
        baseUrl: PATH.SOURCE,
        out: PATH.BUILD + 'common/scripts/site.min.js',
        mainConfigFile: PATH.SOURCE + 'common/scripts/main.js',
        include: ['./vendor/requirejs/require.min.js', './common/scripts/main'],
        insertRequire: ['main'],
        wrap: true,
        optimize: 'uglify2',
        preserveLicenseComments: false
    }, function() {
        return 0;
    }, function(err) {
        console.log(err);
        return 1;
    });
});

gulp.task('optimize-styles', function() {
    return gulp.src([
            PATH.SOURCE + 'vendor/normalize-css/normalize.css',
            PATH.SOURCE + 'vendor/ngDialog/css/ngDialog.min.css',
            PATH.SOURCE + 'common/fonts/**/*.css',
            PATH.SOURCE + 'common/styles/**/*.css'
        ])
        .pipe(concat('site.min.css'))
        .pipe(minifyCSS({ keepSpecialComments: 0 }))
        .pipe(gulp.dest(PATH.BUILD + 'common/styles/'));
});

gulp.task('optimize-html', function() {
    gulp.src(PATH.SOURCE + 'index.html')
        .pipe(prochtml('index.html'))
        .pipe(minifyHTML())
        .pipe(gulp.dest(PATH.BUILD));

    gulp.src([
            PATH.SOURCE + '**/*.html',
            '!' + PATH.SOURCE + 'archives/**/*.html',
            '!' + PATH.SOURCE + 'common/**/*.html',
            '!' + PATH.SOURCE + 'index.html'
        ])
        .pipe(minifyHTML())
        .pipe(gulp.dest(PATH.BUILD));
});

gulp.task('optimize-json', function() {
    return gulp.src(PATH.SOURCE + 'data/**/*.json')
        .pipe(minifyJSON())
        .pipe(replace(/^(\)]}',)(?=\[{".+":.+)/, '$1\n'))
        .pipe(gulp.dest(PATH.BUILD + 'data/'));
});

gulp.task('optimize-images', function() {
    return gulp.src(PATH.SOURCE + 'media/images/**/*')
        .pipe(imagemin())
        .pipe(gulp.dest(PATH.BUILD + 'media/images/'));
});

gulp.task('copy', function() {
    gulp.src([
            PATH.SOURCE + 'fonts/fontello/font/*.eot',
            PATH.SOURCE + 'fonts/fontello/font/*.svg',
            PATH.SOURCE + 'fonts/fontello/font/*.ttf',
            PATH.SOURCE + 'fonts/fontello/font/*.woff',
            PATH.SOURCE + 'fonts/lato/font/*.woff'
        ])
        .pipe(gulp.dest(PATH.BUILD + 'font/'));
});

gulp.task('concat-header-scripts', function() {
    return gulp.src([
            PATH.SOURCE + 'tasks/license.js',
            PATH.BUILD + 'scripts/site.min.js'
        ])
        .pipe(concat('site.min.js'))
        .pipe(gulp.dest(PATH.BUILD + 'scripts/'));
});

gulp.task('concat-header-styles', function() {
    return gulp.src([
            PATH.SOURCE + 'tasks/license.css',
            PATH.BUILD + 'styles/site.min.css'
        ])
        .pipe(concat('site.min.css'))
        .pipe(gulp.dest(PATH.BUILD + 'styles/'));
});

gulp.task('clean', function(done) {
    del([
        PATH.BUILD + 'index.html',
        PATH.BUILD + 'font/',
        PATH.BUILD + 'media/',
        PATH.BUILD + 'partials/',
        PATH.BUILD + 'scripts/',
        PATH.BUILD + 'styles/',
    ], done);
});

gulp.task('post-build-scripts', function() {
    var date = new Date();

    return gulp.src(PATH.BUILD + 'scripts/site.min.js')
        .pipe(replace(/(\/\*!)/, '// scripts.min.js build: ' + date + '\n$1'))
        .pipe(gulp.dest(PATH.BUILD + 'scripts/'));
});

gulp.task('post-build-styles', function() {
    var date = new Date();

    return gulp.src(PATH.BUILD + 'styles/site.min.css')
        .pipe(replace(/(\/\*!)/, '/* site.min.js build: ' + date + ' */\n$1'))
        .pipe(gulp.dest(PATH.BUILD + 'styles/'));
});

gulp.task('size', function() {
    return gulp.src([
            PATH.BUILD + 'index.html',
            PATH.BUILD + 'fonts/**/*',
            PATH.BUILD + 'media/**/*',
            PATH.BUILD + 'partial/**/*',
            PATH.BUILD + 'scripts/**/*',
            PATH.BUILD + 'styles/**/*',
        ])
        .pipe(size({
            gzip: true,
            title: 'build -->'
        }));
});

gulp.task('server-dev', function() {
    gulp.src(PATH.SOURCE)
        .pipe(webserver({
            host: SERVER.HOST,
            port: SERVER.PORT,
            livereload: true
        }));
});

gulp.task('server', function() {
    gulp.src(PATH.BUILD)
        .pipe(webserver({
            host: SERVER.HOST,
            port: SERVER.PORT
        }));
});

gulp.task('build', function() {
    runSequence(
        ['clean', 'lint'],
        ['optimize-styles', 'optimize-scripts', 'optimize-html', 'optimize-json', 'copy'],
        'concat-header-styles',
        'concat-header-scripts',
        ['post-build-styles', 'post-build-scripts'],
        ['size', 'server']
    );
});
<|endoftext|>


<commit_before>/* globals Ember, Proxy */
(function() {
  var HAS_NATIVE_PROXY = typeof Proxy === 'function';

  var FactoryForMixin = Ember.Mixin.create({
    factoryFor: function(fullName) {
      var FactoryManager = {
        class: this._lookupFactory(fullName),

        create: function() {
          return this.class.create.apply(this.class, arguments);
        }
      };

      if (HAS_NATIVE_PROXY) {
        Ember.runInDebug(function() {
          var validator = {
            get: function(obj, prop) {
              if (prop !== 'class' && prop !== 'create') {
                throw new Error('You attempted to access "' + prop + '" on a factory manager created by container#factoryFor. "' + prop + '" is not a member of a factory manager.');
              }

              return obj[prop];
            },
            set: function(obj, prop, value) {
              throw new Error('You attempted to set "' + prop + '" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.');
            }
          };

          // Note:
          // We have to proxy access to the manager here so that private property
          // access doesn't cause the above errors to occur.
          var m = FactoryManager;
          var proxiedManager = {
            class: m.class,
            create: function(props) {
              return m.create(props);
            }
          };

          FactoryManager = new Proxy(proxiedManager, validator);
        });
      }

      return FactoryManager;
    }
  });

  function wrapManagerInDeprecationProxy(manager) {
    if (HAS_NATIVE_PROXY) {

    }

    return manager;
  }

  // augment the main application's "owner"
  Ember.ApplicationInstance.reopen(FactoryForMixin);

  // supports ember-test-helpers's build-registry (and other tooling that use
  // Ember._ContainerProxyMixin to emulate an "owner")
  var ContainerProxyMixinWithFactoryFor = Ember.Mixin.create(Ember._ContainerProxyMixin, FactoryForMixin);
  Ember._ContainerProxyMixin = ContainerProxyMixinWithFactoryFor;
})();
<commit_msg>Guard access to Ember properties.<commit_after>/* globals Ember, Proxy */
(function() {
  var HAS_NATIVE_PROXY = typeof Proxy === 'function';

  var FactoryForMixin = Ember.Mixin.create({
    factoryFor: function(fullName) {
      var FactoryManager = {
        class: this._lookupFactory(fullName),

        create: function() {
          return this.class.create.apply(this.class, arguments);
        }
      };

      if (HAS_NATIVE_PROXY) {
        Ember.runInDebug(function() {
          var validator = {
            get: function(obj, prop) {
              if (prop !== 'class' && prop !== 'create') {
                throw new Error('You attempted to access "' + prop + '" on a factory manager created by container#factoryFor. "' + prop + '" is not a member of a factory manager.');
              }

              return obj[prop];
            },
            set: function(obj, prop, value) {
              throw new Error('You attempted to set "' + prop + '" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.');
            }
          };

          // Note:
          // We have to proxy access to the manager here so that private property
          // access doesn't cause the above errors to occur.
          var m = FactoryManager;
          var proxiedManager = {
            class: m.class,
            create: function(props) {
              return m.create(props);
            }
          };

          FactoryManager = new Proxy(proxiedManager, validator);
        });
      }

      return FactoryManager;
    }
  });

  // added in Ember 2.8
  if (Ember.ApplicationInstance) {
    // augment the main application's "owner"
    Ember.ApplicationInstance.reopen(FactoryForMixin);
  }

  // added in Ember 2.3
  if (Ember._ContainerProxyMixin) {
    // supports ember-test-helpers's build-registry (and other tooling that use
    // Ember._ContainerProxyMixin to emulate an "owner")
    var ContainerProxyMixinWithFactoryFor = Ember.Mixin.create(Ember._ContainerProxyMixin, FactoryForMixin);
    Ember._ContainerProxyMixin = ContainerProxyMixinWithFactoryFor;
  }
})();
<|endoftext|>


<commit_before>/* config for different envs */

const getGraphQLEndpoint = () => {
  /* console.log('process.env: ', process.env) */
  console.log('process.env.GOAL: ', process.env.GOAL)
  /* console.log('process.env.NODE_ENV: ', process.env.NODE_ENV) */
  /* console.log('process.env.NODE_ENV: ', process.env.NODE_ENV) */
  switch (process.env.GOAL) {
    case 'production':
      return 'http://api.coderplanets.com/graphiql'
    /* return 'http://localhost:8000/graphiql' */

    case 'dev':
      return 'http://devapi.coderplanets.com/graphiql'
    /* return 'http://devapi.coderplanets.com' */

    case 'local':
      return 'http://localhost:4001/graphiql'
    /* return 'http://localhost:7000/graphiql' // work */

    default:
      return 'http://localhost:4001/graphiql'
  }
}
export const GRAPHQL_ENDPOINT = getGraphQLEndpoint()
export const GITHUB_ADDR = 'https://github.com/mydearxym/mastani_web'
export const GITHUB_ME = 'https://github.com/mydearxym'
export const ISSUE_ADDR = 'https://github.com/mydearxym/mastani_web/issues/new'
export const MENTION_USER_ADDR = 'https://coderplanets.com/users/'
<commit_msg>refactor: change prod endpoint<commit_after>/* config for different envs */

const getGraphQLEndpoint = () => {
  /* console.log('process.env: ', process.env) */
  console.log('process.env.GOAL: ', process.env.GOAL)
  /* console.log('process.env.NODE_ENV: ', process.env.NODE_ENV) */
  /* console.log('process.env.NODE_ENV: ', process.env.NODE_ENV) */
  switch (process.env.GOAL) {
    case 'production':
      return 'http://api.coderplanets.com/graphiql'

    case 'dev':
      return 'http://devapi.coderplanets.com/graphiql'
    /* return 'http://devapi.coderplanets.com' */

    case 'local':
      return 'http://localhost:4001/graphiql'
    /* return 'http://localhost:7000/graphiql' // work */

    default:
      return 'http://localhost:4001/graphiql'
  }
}
export const GRAPHQL_ENDPOINT = getGraphQLEndpoint()
export const GITHUB_ADDR = 'https://github.com/mydearxym/mastani_web'
export const GITHUB_ME = 'https://github.com/mydearxym'
export const ISSUE_ADDR = 'https://github.com/mydearxym/mastani_web/issues/new'
export const MENTION_USER_ADDR = 'https://coderplanets.com/users/'
<|endoftext|>