<commit_before>// Gulp file to merge sections into a single document and convert to HTML/PDF
// 06/19/2017 - James Ritchie Carroll
//
// Prerequisties needed for execution:
//   Install Node Package Manager: https://nodejs.org/en/download/
//   Install wkhtmltopdf: https://wkhtmltopdf.org/downloads.html
//   Add "C:\Program Files\wkhtmltopdf\bin" to your path
//   From command line after NPM install:
//     npm install gulp
//     npm install --global gulp-cli
//     npm install gulp-util
//     npm install gulp-clean
//     npm install gulp-concat
//     npm install showdown
//     npm install --save showdown-emoji
//     npm install gulp-html2pdf
//     npm install gulp-exec
//     npm install gulp-notify
//
// To execute, just type "gulp" from command window

const gulp = require("gulp");
const clean = require('gulp-clean');
const concat = require("gulp-concat");
const showdown = require("showdown");
const emojis = require("showdown-emoji");
const gutil = require("gulp-util");
const through = require("through2");
const html2pdf = require('gulp-html2pdf');
const exec = require("gulp-exec");
const notify = require("gulp-notify");

// Define non-relative URL root path for any relative paths
const rootPath = "https://raw.githubusercontent.com/sttp/Specification/master/";

// Define section file that contains version number
const versionFile = "Sections/TitlePage.md";

// Define primary footer title for PDF - will be suffixed with updated version
const footerTitle = "STTP Draft Specification - v";

// Define the section files in the order that they should appear
// in the target single combined markdown document:
const sections = [
  "Sections/TitlePage.md",
  "Sections/Preface.md",
  "Sections/README.md" /* TOC */,
  "Sections/Introduction.md",
  "Sections/Definitions.md",
  "Sections/Overview.md",
  "Sections/BusinessCase.md",
  "Sections/DesignPhilosophies.md",
  "Sections/DataPointStructure.md",
  "Sections/CommandsAndResponses.md",
  "Sections/Commands.md",
  "Sections/Responses.md",
  "Sections/DataPointCharacteristics.md",
  "Sections/Metadata.md",
  "Sections/Compression.md",
  "Sections/Security.md",
  /* Balance of sections */
  "Sections/References.md",
  "Sections/Contributors.md",
  "Sections/History.md",
  "Sections/APIReference.md",
  "Sections/IEEE_C37.118Mapping.md",
  "Sections/ToDoList.md"
];

// Define map of markdown file links to intra-page section headers, note
// that GitHub makes all header links lowercase and spaces become dashes:
const sectionLinks = [
  [ "(TitlePage.md)", "(#user-content-title-page)" ],
  [ "(Preface.md)", "(#disclaimer)" ],
  [ "(README.md)", "(#table-of-contents)" ],
  [ "(Introduction.md)", "(#introduction)" ],
  [ "(Definitions.md)", "(#definitions-and-nomenclature)" ],
  [ "(Overview.md)", "(#protocol-overview)" ],
  [ "(BusinessCase.md)", "(#business-case)" ],
  [ "(DesignPhilosophies.md)", "(#design-philosophies)" ],
  [ "(DataPointStructure.md)", "(#data-point-structure)" ],
  [ "(CommandsAndResponses.md)", "(#commands-and-responses)" ],
  [ "(Commands.md)", "(#commands)" ],
  [ "(Responses.md)", "(#responses)" ],
  [ "(DataPointCharacteristics.md)", "(#data-point-characteristics)" ],
  [ "(Metadata.md)", "(#metadata)" ],
  [ "(Compression.md)", "(#compression)" ],
  [ "(Security.md)", "(#security)" ],
  /* Balance of sections */
  [ "(References.md)", "(#references-and-notes)" ],
  [ "(References.md#", "(#" ], /* Handle specific references */
  [ "(Contributors.md)", "(#contributors)" ],
  [ "(History.md)", "(#major-version-history)" ],
  [ "(APIReference.md)", "(#appendix-a---sttp-api-reference)" ],
  [ "(IEEE_C37.118Mapping.md)", "(#appendix-b---ieee-c37118-mapping)" ],
  [ "(ToDoList.md)", "(#specification-development-to-do-list)" ],
  [ "(../LICENSE)", "(" + rootPath + "LICENSE)" ]
];

// Any git functionality expects existing "git" environmental variable
const isWin = /^win/.test(process.platform);
const git = isWin ? "\"%git%\"" : "#git#";
const versionPattern = /^\*\*Version:\*\*\s+\d+\.\d+\.\d+.*$/gm;
const execReportOptions = {
    err: true,    // default = true, false means don't write err
    stderr: true, // default = true, false means don't write stderr
    stdout: false // default = true, false means don't write stdout
};

var currentVersion = null;
var updatedVersion = null;
var forcePush = false;

showdown.setFlavor("github");

function replaceAll(sourceText, findText, replaceWith, ignoreCase) {
  return sourceText.replace(new RegExp(
    findText.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"),
      (ignoreCase ? "gi" : "g")), (typeof replaceWith == "string") ?
        replaceWith.replace(/\$/g, "$$$$") : replaceWith);
}

function getLongDate(date) {
  const monthNames = [
    "January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December"
  ];

  if (!date)
    date = new Date();

  const day = date.getDate();
  const monthIndex = date.getMonth();
  const year = date.getFullYear();

  return monthNames[monthIndex] + " " + day + ", " + year;
}

function checkDocumentVersion() {
  return through.obj(function(file, encoding, cb) {
    const versionLineMatch = file.contents.toString().match(versionPattern);

    if (versionLineMatch) {
      const versionNumber = versionLineMatch[0].match(/\d+\.\d+\.\d+/)[0];
      console.log("Current version number = " + versionNumber);

      currentVersion = versionNumber;

      this.push(file);
      cb(null, file);
    }
    else {
      cb(new Error("Failed to find version pattern: \"**Version:** #.#.#\""));
    }
  });
}

function incrementDocumentVersion() {
  return through.obj(function(file, encoding, cb) {
    const lastDotIndex = currentVersion.lastIndexOf(".");
    const revision = parseInt(currentVersion.substring(lastDotIndex + 1)) + 1;

    updatedVersion = currentVersion.substr(0, lastDotIndex) + "." + revision;

    const updatedMarkdown = file.contents.toString().replace(versionPattern,
      "**Version:** " + updatedVersion + " - " + getLongDate());

    file.contents = new Buffer(updatedMarkdown);
    this.push(file);
    cb(null, file);
  });
}

function pushDocumentUpdates() {
  return through.obj(function(file, encoding, cb) {
    const stdout = file.exec.stdout;
    const stderr = file.exec.stderr;
    const pushUpdates =
      forcePush ||
      (stdout && stdout.length > 0) ||
      (stderr && stderr.length > 0);

    if (pushUpdates) {
      console.log("Committing new compiled documents to local repo...");

      const message = "Updated compiled documents - version " + updatedVersion;

      gulp.src("README.md")
        .pipe(exec(git + " add ."))
        .pipe(exec.reporter(execReportOptions))
        .pipe(exec(git + " commit -m \"" + message + "\""))
        .pipe(exec.reporter(execReportOptions))
        .pipe(notify("Tagging local repo with new version number..."))
        .pipe(exec(git + " tag -f v" + updatedVersion))
        .pipe(exec.reporter(execReportOptions))
        .pipe(notify("Pushing updates to remote repo..."))
        .pipe(exec(git + " push"))
        .pipe(exec.reporter(execReportOptions));
    }

    this.push(file);
    cb(null, file);
  });
}

function updateSectionLinks() {
  return through.obj(function(file, encoding, cb) {
    var sourceMarkdown = file.contents.toString();

    for (let i = 0; i < sectionLinks.length; i++) {
      findText = sectionLinks[i][0];
      replaceWith = sectionLinks[i][1];
      sourceMarkdown = replaceAll(sourceMarkdown, findText, replaceWith);
    }

    file.contents = new Buffer(sourceMarkdown);
    this.push(file);
    cb(null, file);
  });
}

function markdown2html() {
  return through.obj(function(file, encoding, cb) {
    const converter = new showdown.Converter({ extensions: [emojis] });
    const sourceMarkdown = file.contents.toString();
    var destinationHtml = converter.makeHtml(sourceMarkdown);

    // Convert local image links to non-relative permanent paths
    destinationHtml = replaceAll(
      destinationHtml,
      "<img src=\"Images/",
      "<img src=\"" + rootPath + "Output/Images/"
    );

    // Remove "#user-content-" prefixes for page level bookmarks
    destinationHtml = replaceAll(destinationHtml, "#user-content-", "#");

    file.contents = new Buffer(destinationHtml);
    file.path = gutil.replaceExtension(file.path, ".html");
    this.push(file);
    cb(null, file);
  });
}

gulp.task("check-version", [], function() {
  console.log("Checking document version...");

  return gulp.src(versionFile)
    .pipe(checkDocumentVersion());
});

gulp.task("clear-output", [ "check-version" ], function() {
  console.log("Clearing output folder...");

  return gulp.src([
      "Output/Images/",
      "Output/Include/",
      "Output/*"
    ], { read: false })
    .pipe(clean());
});

gulp.task("increment-version", [ "clear-output" ], function() {
  console.log("Incrementing document version number...")

  return gulp.src(versionFile)
    .pipe(incrementDocumentVersion())
    .pipe(gulp.dest("Sections/"));
});

gulp.task("copy-to-output", [ "increment-version" ], function() {
  console.log("Copying target files to output folder...");

  gulp.src("Sections/Images/*")
    .pipe(gulp.dest("Output/Images/"));

  return gulp.src("Sections/Include/*")
    .pipe(gulp.dest("Output/Include/"));
});

gulp.task("merge-markdown", [ "copy-to-output" ], function() {
  console.log("Combining all markdown into a single file...");

  return gulp.src(sections)
    .pipe(concat("README.md"))
    .pipe(updateSectionLinks())
    .pipe(gulp.dest("Output/"));
});

gulp.task("convert-to-html", [ "merge-markdown" ], function() {
  console.log("Converting markdown to HTML...");

  return gulp.src("Output/README.md")
    .pipe(markdown2html())
    .pipe(gulp.dest("Output/"));
});

gulp.task("complete-html", [ "convert-to-html" ], function() {
  console.log("Adding header and footer to HTML...");

  return gulp.src([
      "Output/Include/_header.html",
      "Output/README.html",
      "Output/Include/_footer.html"
    ])
    .pipe(concat("sttp-specification.html"))
    .pipe(gulp.dest("Output/"));
});

gulp.task("convert-to-pdf", [ "complete-html" ], function() {
  console.log("Converting HTML to PDF...");

  const options = {
    marginLeft: 20,
    marginRight: 20,
    marginTop: 20,
    marginBottom: 20,
    footerSpacing: 5,
    footerFontName: "Segoe UI",
    footerFontSize: 8,
    footerLeft: getLongDate(),
    footerCenter: footerTitle + updatedVersion,
    footerRight: "[page] / [toPage]",
    footerLine: false
  };

  return gulp.src("Output/sttp-specification.html")
    .pipe(html2pdf(options))
    .pipe(gulp.dest("Output/"));
});

gulp.task("clean-up", [ "convert-to-pdf" ], function() {
  console.log("Removing temporary files...");

  return gulp.src([
    "Output/Include/",
    "Output/README.html"
  ], { read: false })
  .pipe(clean());
});

// This task will recompile output documents and increment the version
gulp.task("default", [ "clean-up" ]);

// This task will recompile output documents, increment the version and
// push the updated files
gulp.task("push-changes", [ "clean-up" ], function() {
  forcePush = true;

  gulp.src("README.md")
    .pipe(pushDocumentUpdates());
});

// This task will recompile output documents, increment the version and
// push the updated files if there have been any remote check-ins - this
// is useful for an automated nightly-build operation that should only
// run when there have been changes pushed to the remote repository.
// When scheduling this task to run, the "update-repo" task should be
// called before calling the "push-changes-if-remote-updated" task - this
// assumes that the automated build repostory will not be the source of
// any content updates besides incrementing the version number and
// compiling the new documents.
gulp.task("push-changes-if-remote-updated", [ "clean-up" ], function() {
  console.log("Checking for remote updates...");

  const options = { continueOnError: true };

  gulp.src("README.md")
    .pipe(exec(git + " log v" + currentVersion + "..", options))
    .pipe(pushDocumentUpdates());
});

// This task will reset the local repository to the remote - be careful
gulp.task("update-repo", function() {
  console.log("Updating local repo...");

  gulp.src("README.md")
    .pipe(exec(git + " gc"))
    .pipe(exec.reporter(execReportOptions))
    .pipe(exec(git + " fetch"))
    .pipe(exec.reporter(execReportOptions))
    .pipe(exec(git + " reset --hard origin/master"))
    .pipe(exec.reporter(execReportOptions))
    .pipe(exec(git + " clean -f -d -x"))
    .pipe(exec.reporter(execReportOptions));
});
<commit_msg>Added viewPath along with rawPath for non-realative GitHub links<commit_after>// Gulp file to merge sections into a single document and convert to HTML/PDF
// 06/19/2017 - James Ritchie Carroll
//
// Prerequisties needed for execution:
//   Install Node Package Manager: https://nodejs.org/en/download/
//   Install wkhtmltopdf: https://wkhtmltopdf.org/downloads.html
//   Add "C:\Program Files\wkhtmltopdf\bin" to your path
//   From command line after NPM install:
//     npm install gulp
//     npm install --global gulp-cli
//     npm install gulp-util
//     npm install gulp-clean
//     npm install gulp-concat
//     npm install showdown
//     npm install --save showdown-emoji
//     npm install gulp-html2pdf
//     npm install gulp-exec
//     npm install gulp-notify
//
// To execute, just type "gulp" from command window

const gulp = require("gulp");
const clean = require('gulp-clean');
const concat = require("gulp-concat");
const showdown = require("showdown");
const emojis = require("showdown-emoji");
const gutil = require("gulp-util");
const through = require("through2");
const html2pdf = require('gulp-html2pdf');
const exec = require("gulp-exec");
const notify = require("gulp-notify");

// Define non-relative URL paths for any relative paths
const rawPath = "https://raw.githubusercontent.com/sttp/Specification/master/";
const viewPath = "https://github.com/sttp/Specification/blob/master/";

// Define section file that contains version number
const versionFile = "Sections/TitlePage.md";

// Define primary footer title for PDF - will be suffixed with updated version
const footerTitle = "STTP Draft Specification - v";

// Define the section files in the order that they should appear
// in the target single combined markdown document:
const sections = [
  "Sections/TitlePage.md",
  "Sections/Preface.md",
  "Sections/README.md" /* TOC */,
  "Sections/Introduction.md",
  "Sections/Definitions.md",
  "Sections/Overview.md",
  "Sections/BusinessCase.md",
  "Sections/DesignPhilosophies.md",
  "Sections/DataPointStructure.md",
  "Sections/CommandsAndResponses.md",
  "Sections/Commands.md",
  "Sections/Responses.md",
  "Sections/DataPointCharacteristics.md",
  "Sections/Metadata.md",
  "Sections/Compression.md",
  "Sections/Security.md",
  /* Balance of sections */
  "Sections/References.md",
  "Sections/Contributors.md",
  "Sections/History.md",
  "Sections/APIReference.md",
  "Sections/IEEE_C37.118Mapping.md",
  "Sections/ToDoList.md"
];

// Define map of markdown file links to intra-page section headers, note
// that GitHub makes all header links lowercase and spaces become dashes:
const sectionLinks = [
  /* Section link mappings */
  [ "(TitlePage.md)", "(#user-content-title-page)" ],
  [ "(Preface.md)", "(#disclaimer)" ],
  [ "(README.md)", "(#table-of-contents)" ],
  [ "(Introduction.md)", "(#introduction)" ],
  [ "(Definitions.md)", "(#definitions-and-nomenclature)" ],
  [ "(Overview.md)", "(#protocol-overview)" ],
  [ "(BusinessCase.md)", "(#business-case)" ],
  [ "(DesignPhilosophies.md)", "(#design-philosophies)" ],
  [ "(DataPointStructure.md)", "(#data-point-structure)" ],
  [ "(CommandsAndResponses.md)", "(#commands-and-responses)" ],
  [ "(Commands.md)", "(#commands)" ],
  [ "(Responses.md)", "(#responses)" ],
  [ "(DataPointCharacteristics.md)", "(#data-point-characteristics)" ],
  [ "(Metadata.md)", "(#metadata)" ],
  [ "(Compression.md)", "(#compression)" ],
  [ "(Security.md)", "(#security)" ],
  /* Balance of sections */
  [ "(References.md)", "(#references-and-notes)" ],
  [ "(Contributors.md)", "(#contributors)" ],
  [ "(History.md)", "(#major-version-history)" ],
  [ "(APIReference.md)", "(#appendix-a---sttp-api-reference)" ],
  [ "(IEEE_C37.118Mapping.md)", "(#appendix-b---ieee-c37118-mapping)" ],
  [ "(ToDoList.md)", "(#specification-development-to-do-list)" ],
  /* Special replacements */
  [ "(References.md#", "(#" ], /* Handle specific references */
  [ "(QuestionsSummary.md)", "(" + viewPath + "QuestionsSummary.md)" ],
  [ "(../LICENSE)", "(" + viewPath + "LICENSE)" ]
];

// Any git functionality expects existing "git" environmental variable
const isWin = /^win/.test(process.platform);
const git = isWin ? "\"%git%\"" : "#git#";
const versionPattern = /^\*\*Version:\*\*\s+\d+\.\d+\.\d+.*$/gm;
const execReportOptions = {
    err: true,    // default = true, false means don't write err
    stderr: true, // default = true, false means don't write stderr
    stdout: false // default = true, false means don't write stdout
};

var currentVersion = null;
var updatedVersion = null;
var forcePush = false;

showdown.setFlavor("github");

function replaceAll(sourceText, findText, replaceWith, ignoreCase) {
  return sourceText.replace(new RegExp(
    findText.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"),
      (ignoreCase ? "gi" : "g")), (typeof replaceWith == "string") ?
        replaceWith.replace(/\$/g, "$$$$") : replaceWith);
}

function getLongDate(date) {
  const monthNames = [
    "January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December"
  ];

  if (!date)
    date = new Date();

  const day = date.getDate();
  const monthIndex = date.getMonth();
  const year = date.getFullYear();

  return monthNames[monthIndex] + " " + day + ", " + year;
}

function checkDocumentVersion() {
  return through.obj(function(file, encoding, cb) {
    const versionLineMatch = file.contents.toString().match(versionPattern);

    if (versionLineMatch) {
      const versionNumber = versionLineMatch[0].match(/\d+\.\d+\.\d+/)[0];
      console.log("Current version number = " + versionNumber);

      currentVersion = versionNumber;

      this.push(file);
      cb(null, file);
    }
    else {
      cb(new Error("Failed to find version pattern: \"**Version:** #.#.#\""));
    }
  });
}

function incrementDocumentVersion() {
  return through.obj(function(file, encoding, cb) {
    const lastDotIndex = currentVersion.lastIndexOf(".");
    const revision = parseInt(currentVersion.substring(lastDotIndex + 1)) + 1;

    updatedVersion = currentVersion.substr(0, lastDotIndex) + "." + revision;

    const updatedMarkdown = file.contents.toString().replace(versionPattern,
      "**Version:** " + updatedVersion + " - " + getLongDate());

    file.contents = new Buffer(updatedMarkdown);
    this.push(file);
    cb(null, file);
  });
}

function pushDocumentUpdates() {
  return through.obj(function(file, encoding, cb) {
    const stdout = file.exec.stdout;
    const stderr = file.exec.stderr;
    const pushUpdates =
      forcePush ||
      (stdout && stdout.length > 0) ||
      (stderr && stderr.length > 0);

    if (pushUpdates) {
      console.log("Committing new compiled documents to local repo...");

      const message = "Updated compiled documents - version " + updatedVersion;

      gulp.src("README.md")
        .pipe(exec(git + " add ."))
        .pipe(exec.reporter(execReportOptions))
        .pipe(exec(git + " commit -m \"" + message + "\""))
        .pipe(exec.reporter(execReportOptions))
        .pipe(notify("Tagging local repo with new version number..."))
        .pipe(exec(git + " tag -f v" + updatedVersion))
        .pipe(exec.reporter(execReportOptions))
        .pipe(notify("Pushing updates to remote repo..."))
        .pipe(exec(git + " push"))
        .pipe(exec.reporter(execReportOptions));
    }

    this.push(file);
    cb(null, file);
  });
}

function updateSectionLinks() {
  return through.obj(function(file, encoding, cb) {
    var sourceMarkdown = file.contents.toString();

    for (let i = 0; i < sectionLinks.length; i++) {
      findText = sectionLinks[i][0];
      replaceWith = sectionLinks[i][1];
      sourceMarkdown = replaceAll(sourceMarkdown, findText, replaceWith);
    }

    file.contents = new Buffer(sourceMarkdown);
    this.push(file);
    cb(null, file);
  });
}

function markdown2html() {
  return through.obj(function(file, encoding, cb) {
    const converter = new showdown.Converter({ extensions: [emojis] });
    const sourceMarkdown = file.contents.toString();
    var destinationHtml = converter.makeHtml(sourceMarkdown);

    // Convert local image links to non-relative permanent paths
    destinationHtml = replaceAll(
      destinationHtml,
      "<img src=\"Images/",
      "<img src=\"" + rawPath + "Output/Images/"
    );

    // Remove "#user-content-" prefixes for page level bookmarks
    destinationHtml = replaceAll(destinationHtml, "#user-content-", "#");

    file.contents = new Buffer(destinationHtml);
    file.path = gutil.replaceExtension(file.path, ".html");
    this.push(file);
    cb(null, file);
  });
}

gulp.task("check-version", [], function() {
  console.log("Checking document version...");

  return gulp.src(versionFile)
    .pipe(checkDocumentVersion());
});

gulp.task("clear-output", [ "check-version" ], function() {
  console.log("Clearing output folder...");

  return gulp.src([
      "Output/Images/",
      "Output/Include/",
      "Output/*"
    ], { read: false })
    .pipe(clean());
});

gulp.task("increment-version", [ "clear-output" ], function() {
  console.log("Incrementing document version number...")

  return gulp.src(versionFile)
    .pipe(incrementDocumentVersion())
    .pipe(gulp.dest("Sections/"));
});

gulp.task("copy-to-output", [ "increment-version" ], function() {
  console.log("Copying target files to output folder...");

  gulp.src("Sections/Images/*")
    .pipe(gulp.dest("Output/Images/"));

  return gulp.src("Sections/Include/*")
    .pipe(gulp.dest("Output/Include/"));
});

gulp.task("merge-markdown", [ "copy-to-output" ], function() {
  console.log("Combining all markdown into a single file...");

  return gulp.src(sections)
    .pipe(concat("README.md"))
    .pipe(updateSectionLinks())
    .pipe(gulp.dest("Output/"));
});

gulp.task("convert-to-html", [ "merge-markdown" ], function() {
  console.log("Converting markdown to HTML...");

  return gulp.src("Output/README.md")
    .pipe(markdown2html())
    .pipe(gulp.dest("Output/"));
});

gulp.task("complete-html", [ "convert-to-html" ], function() {
  console.log("Adding header and footer to HTML...");

  return gulp.src([
      "Output/Include/_header.html",
      "Output/README.html",
      "Output/Include/_footer.html"
    ])
    .pipe(concat("sttp-specification.html"))
    .pipe(gulp.dest("Output/"));
});

gulp.task("convert-to-pdf", [ "complete-html" ], function() {
  console.log("Converting HTML to PDF...");

  const options = {
    marginLeft: 20,
    marginRight: 20,
    marginTop: 20,
    marginBottom: 20,
    footerSpacing: 5,
    footerFontName: "Segoe UI",
    footerFontSize: 8,
    footerLeft: getLongDate(),
    footerCenter: footerTitle + updatedVersion,
    footerRight: "[page] / [toPage]",
    footerLine: false
  };

  return gulp.src("Output/sttp-specification.html")
    .pipe(html2pdf(options))
    .pipe(gulp.dest("Output/"));
});

gulp.task("clean-up", [ "convert-to-pdf" ], function() {
  console.log("Removing temporary files...");

  return gulp.src([
    "Output/Include/",
    "Output/README.html"
  ], { read: false })
  .pipe(clean());
});

// This task will recompile output documents and increment the version
gulp.task("default", [ "clean-up" ]);

// This task will recompile output documents, increment the version and
// push the updated files
gulp.task("push-changes", [ "clean-up" ], function() {
  forcePush = true;

  gulp.src("README.md")
    .pipe(pushDocumentUpdates());
});

// This task will recompile output documents, increment the version and
// push the updated files if there have been any remote check-ins - this
// is useful for an automated nightly-build operation that should only
// run when there have been changes pushed to the remote repository.
// When scheduling this task to run, the "update-repo" task should be
// called before calling the "push-changes-if-remote-updated" task - this
// assumes that the automated build repostory will not be the source of
// any content updates besides incrementing the version number and
// compiling the new documents.
gulp.task("push-changes-if-remote-updated", [ "clean-up" ], function() {
  console.log("Checking for remote updates...");

  const options = { continueOnError: true };

  gulp.src("README.md")
    .pipe(exec(git + " log v" + currentVersion + "..", options))
    .pipe(pushDocumentUpdates());
});

// This task will reset the local repository to the remote - be careful
gulp.task("update-repo", function() {
  console.log("Updating local repo...");

  gulp.src("README.md")
    .pipe(exec(git + " gc"))
    .pipe(exec.reporter(execReportOptions))
    .pipe(exec(git + " fetch"))
    .pipe(exec.reporter(execReportOptions))
    .pipe(exec(git + " reset --hard origin/master"))
    .pipe(exec.reporter(execReportOptions))
    .pipe(exec(git + " clean -f -d -x"))
    .pipe(exec.reporter(execReportOptions));
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    connect = require('gulp-connect'),
    sass = require('gulp-sass'),
    concat = require('gulp-concat'),
    serve = require('gulp-serve'),
    ghPages = require('gulp-gh-pages'),
    clean = require('gulp-clean'),
    gih = require('gulp-include-html'),
    gulpWebpack = require('gulp-webpack'),
    webpack = require('webpack');

gulp.task('js', () => {
  gulp.src('./src/js/app.js')
    .pipe(gulpWebpack({
      entry: [
        './src/js/app.js',
      ],
      output: {
        filename: 'app.bundle.js',
      },
      module: {
        loaders: [
          {
            test: /\.js$/,
            exclude: 'node_modules', //add bower components later for jquery?
            loader: "babel-loader",
            query: {
              presets: ['es2015']
            }
          }
        ]
      },
      plugins: [new webpack.optimize.UglifyJsPlugin()],
      }, webpack))
    .pipe(gulp.dest('dest/assets'))
    .pipe(connect.reload());
});

gulp.task('sass', () => {
  gulp.src('./src/sass/app.scss')
    .pipe(sass().on('error', gutil.log))
    .pipe(gulp.dest('dest/assets'))
    .pipe(connect.reload());
});

gulp.task('html', () => {
  gulp.src(['./*.html', './views/*.html'])
    .pipe(gih({
      baseDir:'./views/',
      ignore:'./views/',
    }))
    .pipe(gulp.dest('dest'))
    .pipe(connect.reload());
});

gulp.task('connect', () => {
  connect.server({
    root: ['dest'],
    port: 8080,
    livereload: true
  })
});

gulp.task('watch', () => {
  gulp.watch(['./*.html', './templates/*.html'], ['html']);
  gulp.watch(['./src/sass/*.scss'], ['sass']);
  gulp.watch(['./src/js/*.js'], ['js']);
});

gulp.task('build', ['html', 'sass', 'js']);

gulp.task('serve', ['build'], serve('dest'));

// gulp.task('deploy', ['build'], function () {
//   gulp.src('./dest/**/*')
//     .pipe(ghPages({
//       remoteUrl: 'url to your gh page',
//       branch: 'master'
//     }))
// });

gulp.task('default', ['connect', 'watch', 'build']);
<commit_msg>updated gulp watch again<commit_after>'use strict';

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    connect = require('gulp-connect'),
    sass = require('gulp-sass'),
    concat = require('gulp-concat'),
    serve = require('gulp-serve'),
    ghPages = require('gulp-gh-pages'),
    clean = require('gulp-clean'),
    gih = require('gulp-include-html'),
    gulpWebpack = require('gulp-webpack'),
    webpack = require('webpack');

gulp.task('js', () => {
  gulp.src('./src/js/app.js')
    .pipe(gulpWebpack({
      entry: [
        './src/js/app.js',
      ],
      output: {
        filename: 'app.bundle.js',
      },
      module: {
        loaders: [
          {
            test: /\.js$/,
            exclude: 'node_modules', //add bower components later for jquery?
            loader: "babel-loader",
            query: {
              presets: ['es2015']
            }
          }
        ]
      },
      plugins: [new webpack.optimize.UglifyJsPlugin()],
      }, webpack))
    .pipe(gulp.dest('dest/assets'))
    .pipe(connect.reload());
});

gulp.task('sass', () => {
  gulp.src('./src/sass/app.scss')
    .pipe(sass().on('error', gutil.log))
    .pipe(gulp.dest('dest/assets'))
    .pipe(connect.reload());
});

gulp.task('html', () => {
  gulp.src(['./*.html', './views/*.html'])
    .pipe(gih({
      baseDir:'./views/',
      ignore:'./views/',
    }))
    .pipe(gulp.dest('dest'))
    .pipe(connect.reload());
});

gulp.task('connect', () => {
  connect.server({
    root: ['dest'],
    port: 8080,
    livereload: true
  })
});

gulp.task('watch', () => {
  gulp.watch(['./*.html', './views/*.html'], ['html']);
  gulp.watch(['./src/sass/*.scss'], ['sass']);
  gulp.watch(['./src/js/*.js'], ['js']);
});

gulp.task('build', ['html', 'sass', 'js']);

gulp.task('serve', ['build'], serve('dest'));

// gulp.task('deploy', ['build'], function () {
//   gulp.src('./dest/**/*')
//     .pipe(ghPages({
//       remoteUrl: 'url to your gh page',
//       branch: 'master'
//     }))
// });

gulp.task('default', ['connect', 'watch', 'build']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var connect = require('gulp-connect');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var recess = require('gulp-recess');
var jshint = require('gulp-jshint');
var karma = require('gulp-karma');

var externalSources = [
    'app/components/jquery/jquery.js',
    'app/components/jquery-ui/ui/jquery-ui.js',
    'app/components/markitup/markitup/jquery.markitup.js',
    'app/components/marked/lib/marked.js',
    'app/components/lodash/dist/lodash.js',
    'app/components/lazy.js/lazy.js',
    'app/components/emoticons/lib/emoticons.js',
    'app/components/underscore.string/lib/underscore.string.js',
    'app/components/angular/angular.js',
    'app/components/angular-route/angular-route.js',
    'app/components/angular-sanitize/angular-sanitize.js',
    'app/components/angular-animate/angular-animate.js',
    'app/js/bootstrap.js',
    'app/components/moment/moment.js',
    'app/components/kalendae/build/kalendae.js',
    'app/components/checksley/checksley.js',
    'app/js/sha1.js',
    'app/components/jscache/cache.js',
    'app/components/jquery-flot/jquery.flot.js',
    'app/components/jquery-flot/jquery.flot.pie.js',
    'app/components/jquery-flot/jquery.flot.time.js',
    'app/components/flot-orderBars/js/jquery.flot.orderBars.js',
    'app/js/curvedLines.js',
    'app/js/emoticons-define.js',
    'app/components/select2/select2.js',
    'app/components/i18next/release/i18next-1.7.1.js',
    'app/js/coffeeColorPicker.js',
    'app/js/coffeeColorPicker.angular.js',
    'app/components/google-diff-match-patch-js/diff_match_patch_uncompressed.js',
    'app/components/jqueryui-touch-punch/jquery.ui.touch-punch.js',
    'app/js/highlight.pack.js',
    'app/components/jquery-textcomplete/jquery.textcomplete.js'
];

var coffeeSources = [
    'app/coffee/**/*.coffee',
    'app/coffee/*.coffee'
];

// define tasks here
gulp.task('default', ['dev', 'watch', 'connect']);

gulp.task('dev', ['coffee', 'less', 'libs']);

gulp.task('pro', ['less'], function() {
    gulp.src(coffeeSources)
        .pipe(coffee())
        .pipe(concat('app.js'))
        .pipe(uglify())
        .pipe(gulp.dest('app/dist/'));
    gulp.src(externalSources)
        .pipe(concat('libs.js'))
        .pipe(uglify())
        .pipe(gulp.dest('app/dist/'));
});

gulp.task('coffee', function() {
    gulp.src(coffeeSources)
        .pipe(coffee())
        .pipe(concat('app.js'))
        .pipe(gulp.dest('app/dist/'));
});

gulp.task('hint', function() {
    gulp.src(coffeeSources)
        .pipe(coffee())
        .pipe(jshint())
        .pipe(jshint.reporter('default'))
});

gulp.task('less', function() {
    gulp.src('app/less/taiga-main.less')
        .pipe(less())
        .pipe(concat('style.css'))
        .pipe(gulp.dest('app/less'));
});

gulp.task('libs', function() {
    gulp.src(externalSources)
        .pipe(concat('libs.js'))
        .pipe(gulp.dest('app/dist/'));
});

gulp.task('lint', function() {
    gulp.src(coffeeSources)
        .pipe(coffeelint('coffeelint.json'))
        .pipe(coffeelint.reporter())
    gulp.src('app/less/taiga-main.less')
        .pipe(recess({strictPropertyOrder: false}))
});

gulp.task('build-tests', function() {
    gulp.src(['test/**/*.coffee'])
        .pipe(coffee({'bare': true}))
        .pipe(concat('tests.js'))
        .pipe(gulp.dest('test'));
});

gulp.task('test', ['coffee', 'libs', 'build-tests'], function() {
    gulp.src(['app/dist/libs.js', 'app/dist/app.js', 'test/tests.js'])
        .pipe(karma({configFile: "karma.conf.coffee", action: 'run'}));
});

gulp.task('watch', function () {
    gulp.watch(['app/less/*.less', 'app/less/**/*.less', 'app/less/**/*.css'], ['less']);
    gulp.watch(externalSources, ['libs']);
    gulp.watch(['app/coffee/*.coffee', 'app/coffee/**/*.coffee'], ['coffee']);
});

gulp.task('connect', connect.server({
    root: 'app',
    port: 9001,
    livereload: true,
}));
<commit_msg>More robust gulp configuration<commit_after>var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var connect = require('gulp-connect');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var recess = require('gulp-recess');
var jshint = require('gulp-jshint');
var karma = require('gulp-karma');
var gutil = require('gulp-util');

var externalSources = [
    'app/components/jquery/jquery.js',
    'app/components/jquery-ui/ui/jquery-ui.js',
    'app/components/markitup/markitup/jquery.markitup.js',
    'app/components/marked/lib/marked.js',
    'app/components/lodash/dist/lodash.js',
    'app/components/lazy.js/lazy.js',
    'app/components/emoticons/lib/emoticons.js',
    'app/components/underscore.string/lib/underscore.string.js',
    'app/components/angular/angular.js',
    'app/components/angular-route/angular-route.js',
    'app/components/angular-sanitize/angular-sanitize.js',
    'app/components/angular-animate/angular-animate.js',
    'app/js/bootstrap.js',
    'app/components/moment/moment.js',
    'app/components/kalendae/build/kalendae.js',
    'app/components/checksley/checksley.js',
    'app/js/sha1.js',
    'app/components/jscache/cache.js',
    'app/components/jquery-flot/jquery.flot.js',
    'app/components/jquery-flot/jquery.flot.pie.js',
    'app/components/jquery-flot/jquery.flot.time.js',
    'app/components/flot-orderBars/js/jquery.flot.orderBars.js',
    'app/js/curvedLines.js',
    'app/js/emoticons-define.js',
    'app/components/select2/select2.js',
    'app/components/i18next/release/i18next-1.7.1.js',
    'app/js/coffeeColorPicker.js',
    'app/js/coffeeColorPicker.angular.js',
    'app/components/google-diff-match-patch-js/diff_match_patch_uncompressed.js',
    'app/components/jqueryui-touch-punch/jquery.ui.touch-punch.js',
    'app/js/highlight.pack.js',
    'app/components/jquery-textcomplete/jquery.textcomplete.js'
];

var coffeeSources = [
    'app/coffee/**/*.coffee',
    'app/coffee/*.coffee'
];

// define tasks here
gulp.task('default', ['dev', 'watch', 'connect']);

gulp.task('dev', ['coffee', 'less', 'libs']);

gulp.task('pro', ['less'], function() {
    gulp.src(coffeeSources)
        .pipe(coffee().on('error', gutil.log))
        .pipe(concat('app.js'))
        .pipe(uglify())
        .pipe(gulp.dest('app/dist/'));
    gulp.src(externalSources)
        .pipe(concat('libs.js'))
        .pipe(uglify())
        .pipe(gulp.dest('app/dist/'));
});

gulp.task('coffee', function() {
    gulp.src(coffeeSources)
        .pipe(coffee().on('error', gutil.log))
        .pipe(concat('app.js'))
        .pipe(gulp.dest('app/dist/'));
});

gulp.task('hint', function() {
    gulp.src(coffeeSources)
        .pipe(coffee().on('error', gutil.log))
        .pipe(jshint())
        .pipe(jshint.reporter('default'))
});

gulp.task('less', function() {
    gulp.src('app/less/taiga-main.less')
        .pipe(less().on('error', gutil.log))
        .pipe(concat('style.css'))
        .pipe(gulp.dest('app/less'));
});

gulp.task('libs', function() {
    gulp.src(externalSources)
        .pipe(concat('libs.js'))
        .pipe(gulp.dest('app/dist/'));
});

gulp.task('lint', function() {
    gulp.src(coffeeSources)
        .pipe(coffeelint('coffeelint.json'))
        .pipe(coffeelint.reporter())
    gulp.src('app/less/taiga-main.less')
        .pipe(recess({strictPropertyOrder: false}))
});

gulp.task('build-tests', function() {
    gulp.src(['test/**/*.coffee'])
        .pipe(coffee({'bare': true}).on('error', gutil.log))
        .pipe(concat('tests.js'))
        .pipe(gulp.dest('test'));
});

gulp.task('test', ['coffee', 'libs', 'build-tests'], function() {
    gulp.src(['app/dist/libs.js', 'app/dist/app.js', 'test/tests.js'])
        .pipe(karma({configFile: "karma.conf.coffee", action: 'run'}));
});

gulp.task('watch', function () {
    gulp.watch(['app/less/*.less', 'app/less/**/*.less', 'app/less/**/*.css'], ['less']);
    gulp.watch(externalSources, ['libs']);
    gulp.watch(['app/coffee/*.coffee', 'app/coffee/**/*.coffee'], ['coffee']);
});

gulp.task('connect', connect.server({
    root: 'app',
    port: 9001,
    livereload: true,
}));
<|endoftext|>


<commit_before>"use strict";
var gulp = require("gulp");
var path = require("path");
var rename = require("gulp-rename");
var inlining = require("gulp-inlining-node-require");
var removeUseString = require("gulp-remove-use-strict");
var browserify = require('browserify');
var minifyify = require("minifyify");
var source = require('vinyl-source-stream');
var sourceFile = "./public/js/index.js";
gulp.task("build-js", function () {
    return browserify(sourceFile)
        .bundle()
        .pipe(source("app.js"))
        .pipe(gulp.dest("./public/js/"));
});
gulp.task("build-min-js", function () {
    return browserify(sourceFile)
        .plugin('minifyify', {
            map: 'app.min.js.map',
            output: './public/js/app.min.js.map'
        })
        .bundle()
        .pipe(source("app.js"))
        .pipe(gulp.dest("./public/js/"));
});
gulp.task("embed", function () {
    return gulp.src(["./Ch*/src/**/*.js", "./Ch*/lib/*.js", "./Ch3_Testing/test/*.js"], {base: './'})
        .pipe(inlining())
        .pipe(removeUseString())
        .pipe(rename(function (filePath) {
            var filePathBySplit = filePath.dirname.split(path.sep);
            filePathBySplit.pop();
            // src 以下の階層
            if (filePathBySplit[filePathBySplit.length - 1] === "src") {
                filePathBySplit.pop();
            }
            filePath.dirname = filePathBySplit.join("/") + "/embed";
            filePath.basename = "embed-" + filePath.basename;
        }))
        .pipe(gulp.dest("./"));
});
gulp.task("lint-html", function (callback) {
    global.Promise = require("ypromise");
    var File = require("./Ch4_AdvancedPromises/src/promise-chain/fs-promise-chain");
    var checkHTML = require("./test/html/missing-internal-link").checkInternalLinks;

    var htmlPromise = File.read("index.html").then(function (contents) {
        var errors = checkHTML(contents);
        if (errors.length > 0) {
            errors.forEach(function (error) {
                console.error(error.message);
            });
            return callback(new Error("Found lint error"));
        }
        callback();
    });
    var asciidocPromise = require("./test/inline-script/inline-script-tester")
        .checkInlineScript("./");
    Promise.all([htmlPromise, asciidocPromise])
        .catch(callback);
});
gulp.on('err', function (error) {
    process.exit(1);
});<commit_msg>chore(gulp): use relative path<commit_after>"use strict";
var gulp = require("gulp");
var path = require("path");
var rename = require("gulp-rename");
var inlining = require("gulp-inlining-node-require");
var removeUseString = require("gulp-remove-use-strict");
var browserify = require('browserify');
var minifyify = require("minifyify");
var source = require('vinyl-source-stream');
var sourceFile = "./public/js/index.js";
gulp.task("build-js", function () {
    return browserify(sourceFile)
        .bundle()
        .pipe(source("app.js"))
        .pipe(gulp.dest("./public/js/"));
});
gulp.task("build-min-js", function () {
    return browserify(sourceFile)
        .plugin('minifyify', {
            map: 'app.min.js.map',
            output: './public/js/app.min.js.map',
            compressPath: function (p) {
                return path.relative('./', p);
            }
        })
        .bundle()
        .pipe(source("app.js"))
        .pipe(gulp.dest("./public/js/"));
});
gulp.task("embed", function () {
    return gulp.src(["./Ch*/src/**/*.js", "./Ch*/lib/*.js", "./Ch3_Testing/test/*.js"], {base: './'})
        .pipe(inlining())
        .pipe(removeUseString())
        .pipe(rename(function (filePath) {
            var filePathBySplit = filePath.dirname.split(path.sep);
            filePathBySplit.pop();
            // src 以下の階層
            if (filePathBySplit[filePathBySplit.length - 1] === "src") {
                filePathBySplit.pop();
            }
            filePath.dirname = filePathBySplit.join("/") + "/embed";
            filePath.basename = "embed-" + filePath.basename;
        }))
        .pipe(gulp.dest("./"));
});
gulp.task("lint-html", function (callback) {
    global.Promise = require("ypromise");
    var File = require("./Ch4_AdvancedPromises/src/promise-chain/fs-promise-chain");
    var checkHTML = require("./test/html/missing-internal-link").checkInternalLinks;

    var htmlPromise = File.read("index.html").then(function (contents) {
        var errors = checkHTML(contents);
        if (errors.length > 0) {
            errors.forEach(function (error) {
                console.error(error.message);
            });
            return callback(new Error("Found lint error"));
        }
        callback();
    });
    var asciidocPromise = require("./test/inline-script/inline-script-tester")
        .checkInlineScript("./");
    Promise.all([htmlPromise, asciidocPromise])
        .catch(callback);
});
gulp.on('err', function (error) {
    process.exit(1);
});<|endoftext|>


<commit_before>var gulp          = require('gulp');
var sass          = require('gulp-sass');
var browserSync   = require('browser-sync').create();
var uglify        = require('gulp-uglify');
var cssnano       = require('gulp-cssnano');
var gutil         = require('gulp-util');
var runSequence   = require('run-sequence');
var run           = require('gulp-run');
var autoprefixer  = require('gulp-autoprefixer');

var sass_path = '_app/assets/sass';
var site_css_path = '_site/_app/assets/css';

var config = {
  drafts:     !!gutil.env.drafts
};

var jekyllDir = '';

gulp.task('watch', function() {
  gulp.watch([sass_path + '/*.sass', sass_path + '/pages/*.sass', sass_path + '/partials/*.sass', sass_path + '/modules/*.sass', sass_path + '/media/*.sass', sass_path + '/helpers/*.sass', sass_path + '/base/*.sass'], ['sass-watch']);

  gulp.watch(['_config.yml'], ['jekyll-watch']);

  gulp.watch('_app/assets/js/*.js', ['js']);

  gulp.watch('_posts/**/*.+(md|markdown|MD)', ['jekyll-watch']);

  if (config.drafts) {
    gulp.watch('_drafts/*.+(md|markdown|MD)', ['jekyll-watch']);
  }

  gulp.watch(['*.html', '*.php', '_app/php/*.php', '_app/php/**/*.php', '_layouts/*.html', '_includes/*.html', 'portfolio/*.html', 'tags/*.html', '_posts/blog/*.html', 'resources/*.html', '!_site/**/*.*'], ['jekyll-watch']);

  gulp.watch('favicon.ico', ['jekyll-watch']);
});

gulp.task('vendor', function() {
  gulp.src(['_app/assets/vendor/highlightjs/**/*.css'], { 'base': '_app/assets/vendor' })
    .pipe(autoprefixer({ browsers: ['last 3 versions', '> 0.5%'] }))
    .pipe(cssnano())
    .pipe(gulp.dest('_site/_app/assets/vendor'))
  gulp.src(['_app/assets/vendor/highlightjs/**/*.js'], { 'base': '_app/assets/vendor' })
    .pipe(uglify())
    .pipe(gulp.dest('_site/_app/assets/vendor'))
  gulp.src(['_app/assets/vendor/highlightjs/**/*'], { 'base': '_app/assets/vendor' })
    .pipe(gulp.dest('_site/_app/assets/vendor'))
})

gulp.task('sass', function() {
  return gulp.src([sass_path + '/pages/*.sass', sass_path + '/all.sass'])
    .pipe(sass())
    .pipe(autoprefixer({ browsers: ['last 3 versions', '> 0.5%'] }))
    .pipe(cssnano())
    .pipe(gulp.dest(site_css_path))
    .pipe(browserSync.reload({
      stream: true
    }));
});

gulp.task('browserSync', function () {
  browserSync.init({
    server: {
      baseDir: '_site',
      port: 3000
    },
    browser: 'chrome',
    open: false
  })
});

gulp.task('js', function () {
  return gulp.src(['_app/assets/js/*.js'])
    .pipe(uglify())
    .pipe(gulp.dest('_site/_app/assets/js'))
    .pipe(browserSync.reload({
      stream: true
    }));
})

gulp.task('node_modules', function () {
  gulp.src(['node_modules/rellax/**/*', 'node_modules/@gabriel-delepine/smooth-scroll/**/*'], { 'base': 'node_modules' })
    .pipe(gulp.dest('_site/node_modules'))
})

gulp.task('images', function () {
  return gulp.src(['_app/assets/img/min/**/*.+(png|jpg|gif|svg)'])
    .pipe(gulp.dest('_site/_app/assets/img'))
})

gulp.task('php', function () {
  return gulp.src(['_app/**/*.php'])
    .pipe(gulp.dest('_site/_app/'))
})

gulp.task('jekyll', function() {
  var shellCommand = 'jekyll build';
  if (config.drafts) { shellCommand += ' --drafts'; };

  return gulp.src(jekyllDir)
    .pipe(run(shellCommand))
    .on('error', gutil.log);
});

gulp.task('build', function(cb) {
  runSequence('jekyll', 'php', 'images', 'sass', 'node_modules', 'vendor', 'js', cb);
});

gulp.task('sass-watch', ['sass'], function(cb) {
  runSequence('jekyll');
  browserSync.reload();
  cb();
});

gulp.task('jekyll-watch', ['jekyll', 'php'], function(cb) {
  browserSync.reload();
  cb();
});

gulp.task('default', ['build'], function() {
  runSequence(['browserSync', 'watch']);
});
<commit_msg>Clean up some things in Gulp file<commit_after>var gulp          = require('gulp');
var sass          = require('gulp-sass');
var browserSync   = require('browser-sync').create();
var uglify        = require('gulp-uglify');
var cssnano       = require('gulp-cssnano');
var gutil         = require('gulp-util');
var runSequence   = require('run-sequence');
var run           = require('gulp-run');
var autoprefixer  = require('gulp-autoprefixer');

var sass_path = '_app/assets/sass';
var site_css_path = '_site/_app/assets/css';

var config = {
  drafts:     !!gutil.env.drafts
};

var jekyllDir = '';

gulp.task('watch', function () {
  gulp.watch([sass_path + '/*.sass', sass_path + '/pages/*.sass', sass_path + '/partials/*.sass', sass_path + '/modules/*.sass', sass_path + '/media/*.sass', sass_path + '/helpers/*.sass', sass_path + '/base/*.sass'], ['sass-watch']);

  gulp.watch(['_config.yml'], ['jekyll-watch']);

  gulp.watch('_app/assets/js/*.js', ['js']);

  gulp.watch('_posts/**/*.+(md|markdown|MD)', ['jekyll-watch']);

  if (config.drafts) {
    gulp.watch('_drafts/*.+(md|markdown|MD)', ['jekyll-watch']);
  }

  gulp.watch(['*.html', '*.php', '_app/php/*.php', '_app/php/**/*.php', '_layouts/*.html', '_includes/*.html', 'portfolio/*.html', 'tags/*.html', '_posts/blog/*.html', 'resources/*.html', '!_site/**/*.*'], ['jekyll-watch']);

  gulp.watch('favicon.ico', ['jekyll-watch']);
});

gulp.task('vendor', function () {
  gulp.src(['_app/assets/vendor/highlightjs/**/*.css'], { 'base': '_app/assets/vendor' })
    .pipe(autoprefixer({ browsers: ['last 3 versions', '> 0.5%'] }))
    .pipe(cssnano())
    .pipe(gulp.dest('_site/_app/assets/vendor'));
  gulp.src(['_app/assets/vendor/highlightjs/**/*.js'], { 'base': '_app/assets/vendor' })
    .pipe(uglify())
    .pipe(gulp.dest('_site/_app/assets/vendor'));
  gulp.src(['_app/assets/vendor/highlightjs/**/*'], { 'base': '_app/assets/vendor' })
    .pipe(gulp.dest('_site/_app/assets/vendor'));
});

gulp.task('sass', function () {
  return gulp.src([sass_path + '/pages/*.sass', sass_path + '/all.sass'])
    .pipe(sass())
    .pipe(autoprefixer({ browsers: ['last 3 versions', '> 0.5%'] }))
    .pipe(cssnano())
    .pipe(gulp.dest(site_css_path))
    .pipe(browserSync.reload({
      stream: true
    }));
});

gulp.task('browserSync', function () {
  browserSync.init({
    server: {
      baseDir: '_site',
      port: 3000
    },
    browser: 'chrome',
    open: false
  });
});

gulp.task('js', function () {
  return gulp.src(['_app/assets/js/*.js'])
    .pipe(uglify())
    .pipe(gulp.dest('_site/_app/assets/js'))
    .pipe(browserSync.reload({
      stream: true
    }));
});

gulp.task('node_modules', function () {
  gulp.src(['node_modules/rellax/**/*', 'node_modules/@gabriel-delepine/smooth-scroll/**/*'], { 'base': 'node_modules' })
    .pipe(gulp.dest('_site/node_modules'));
});

gulp.task('images', function () {
  return gulp.src(['_app/assets/img/min/**/*.+(png|jpg|gif|svg)'])
    .pipe(gulp.dest('_site/_app/assets/img'));
});

gulp.task('php', function () {
  return gulp.src(['_app/**/*.php'])
    .pipe(gulp.dest('_site/_app/'));
});

gulp.task('jekyll', function () {
  var shellCommand = 'jekyll build';
  if (config.drafts) { shellCommand += ' --drafts'; };

  return gulp.src(jekyllDir)
    .pipe(run(shellCommand))
    .on('error', gutil.log);
});

gulp.task('build', function (cb) {
  runSequence('jekyll', 'php', 'images', 'sass', 'node_modules', 'vendor', 'js', cb);
});

gulp.task('sass-watch', ['sass'], function (cb) {
  runSequence('jekyll');
  browserSync.reload();
  cb();
});

gulp.task('jekyll-watch', ['jekyll', 'php'], function (cb) {
  browserSync.reload();
  cb();
});

gulp.task('default', ['build'], function () {
  runSequence(['browserSync', 'watch']);
});
<|endoftext|>


<commit_before>var body = document.body;
var html = document.documentElement;
var table = document.getElementsByClassName('snaketable')[0];

var size = 30; // Size of cell
var height = 10;
var width = 15;

if (isMobile) {
	size = 75;
	height = 15;
	width = 10;
	refreshRate = 350;
	table.setAttribute('cellspacing', '2px');
}
table.setAttribute('height', height*size + 'px');
table.setAttribute('width', width*size + 'px');
table.setAttribute('cellspacing', '1px');
table.setAttribute('cellpadding', '0px');
for (var i=0; i<height; i+=1) {
	var row = table.insertRow(i);
	for (var j=0; j<width; j+=1) {
		var cell = row.insertCell(j);
		cell.setAttribute('name', j+'_'+i);
		var btn = document.createElement('button');
		btn.setAttribute('class', 'invisible');
		btn.setAttribute('onclick', 'placeFood('+j+','+i+')');
		btn.setAttribute('height', size+'px');
		btn.setAttribute('width', size+'px');
		cell.appendChild(btn);
	}
}

function updateBoard() {
	for (var r=0; r<table.rows.length; r++) {
		for (var c=0; c<table.rows[r].cells.length; c++) {
			var cell = table.rows[r].cells[c];
			if (inSnake(cell.getAttribute('name'))) {
				cell.setAttribute('class', 'snakecell');
			} else if (cell.getAttribute('name') == food[0]+'_'+food[1]) {
        cell.setAttribute('class', 'foodcell');
      } else {
				cell.setAttribute('class', 'emptycell');
			}
			cell.setAttribute('height', size+'px');
			cell.setAttribute('width', size+'px');
		}
	}
}

updateBoard();
<commit_msg>Fixed height/width not setting properly.<commit_after>var body = document.body;
var html = document.documentElement;
var table = document.getElementsByClassName('snaketable')[0];

var size = 30; // Size of cell
var height = 10;
var width = 15;

if (isMobile) {
	size = 75;
	height = 15;
	width = 10;
	refreshRate = 350;
	table.setAttribute('cellspacing', '2px');
}
table.setAttribute('height', height*size + 'px');
table.setAttribute('width', width*size + 'px');
table.setAttribute('cellspacing', '1px');
table.setAttribute('cellpadding', '0px');
for (var i=0; i<height; i+=1) {
	var row = table.insertRow(i);
	for (var j=0; j<width; j+=1) {
		var cell = row.insertCell(j);
		cell.setAttribute('name', j+'_'+i);
		var btn = document.createElement('button');
		btn.setAttribute('class', 'invisible');
		btn.setAttribute('onclick', 'placeFood('+j+','+i+')');
		btn.style.height = size+'px';
		btn.style.width = size+'px';
		cell.appendChild(btn);
	}
}

function updateBoard() {
	for (var r=0; r<table.rows.length; r++) {
		for (var c=0; c<table.rows[r].cells.length; c++) {
			var cell = table.rows[r].cells[c];
			if (inSnake(cell.getAttribute('name'))) {
				cell.setAttribute('class', 'snakecell');
			} else if (cell.getAttribute('name') == food[0]+'_'+food[1]) {
        cell.setAttribute('class', 'foodcell');
      } else {
				cell.setAttribute('class', 'emptycell');
			}
			cell.setAttribute('height', size+'px');
			cell.setAttribute('width', size+'px');
		}
	}
}

updateBoard();
<|endoftext|>


<commit_before>const gulp = require("gulp");
const path = require("path");

const ts = require("gulp-typescript");
const typescript = require("typescript");
const sourcemaps = require("gulp-sourcemaps");
const del = require("del");
const runSequence = require("run-sequence");
const es = require("event-stream");
const vsce = require("vsce");
const nls = require("vscode-nls-dev");

const tsProject = ts.createProject("./tsconfig.json", { typescript });

const inlineMap = true;
const inlineSource = false;
const outDest = "out";

// If all VS Code langaues are support you can use nls.coreLanguages
const languages = ["jpn"];

gulp.task("default", function(callback) {
    runSequence("build", callback);
});

gulp.task("compile", function(callback) {
    runSequence("clean", "internal-compile", callback);
});

gulp.task("build", function(callback) {
    runSequence("clean", "internal-nls-compile", "add-i18n", callback);
});

gulp.task("publish", function(callback) {
    runSequence("build", "vsce:publish", callback);
});

gulp.task("clean", function() {
    return del(["out/**", "package.nls.*.json"]);
});

// ---- internal

function compile(buildNls) {
    var r = tsProject.src()
        .pipe(sourcemaps.init())
        .pipe(tsProject()).js
        .pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
        .pipe(buildNls ? nls.createAdditionalLanguageFiles(languages, "i18n", "out") : es.through());

    if (inlineMap && inlineSource) {
        r = r.pipe(sourcemaps.write());
    } else {
        r = r.pipe(sourcemaps.write("../out", {
            // no inlined source
            includeContent: inlineSource,
            // Return relative source map root directories per file.
            sourceRoot: "../src"
        }));
    }

    return r.pipe(gulp.dest(outDest));
}

gulp.task("internal-compile", function() {
    return compile(false);
});

gulp.task("internal-nls-compile", function() {
    return compile(true);
});

gulp.task("add-i18n", function() {
    return gulp.src(["package.nls.json"])
        .pipe(nls.createAdditionalLanguageFiles(languages, "i18n"))
        .pipe(gulp.dest("."));
});

gulp.task("vsce:publish", function() {
    return vsce.publish();
});
<commit_msg>upgrade gulpfile to gulp 4<commit_after>const gulp = require("gulp");
const path = require("path");

const ts = require("gulp-typescript");
const typescript = require("typescript");
const sourcemaps = require("gulp-sourcemaps");
const del = require("del");
const es = require("event-stream");
const vsce = require("vsce");
const nls = require("vscode-nls-dev");

const tsProject = ts.createProject("./tsconfig.json", { typescript });

const inlineMap = true;
const inlineSource = false;
const outDest = "out";

// If all VS Code langaues are support you can use nls.coreLanguages
const languages = ["jpn"];

// ---- internal

function compile(buildNls) {
    var r = tsProject.src()
        .pipe(sourcemaps.init())
        .pipe(tsProject()).js
        .pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
        .pipe(buildNls ? nls.createAdditionalLanguageFiles(languages, "i18n", "out") : es.through());

    if (inlineMap && inlineSource) {
        r = r.pipe(sourcemaps.write());
    } else {
        r = r.pipe(sourcemaps.write("../out", {
            // no inlined source
            includeContent: inlineSource,
            // Return relative source map root directories per file.
            sourceRoot: "../src"
        }));
    }

    return r.pipe(gulp.dest(outDest));
}

gulp.task("internal-compile", function() {
    return compile(false);
});

gulp.task("internal-nls-compile", function() {
    return compile(true);
});

gulp.task("add-i18n", function() {
    return gulp.src(["package.nls.json"])
        .pipe(nls.createAdditionalLanguageFiles(languages, "i18n"))
        .pipe(gulp.dest("."));
});

gulp.task("vsce:publish", function() {
    return vsce.publish();
});

// ---- external

gulp.task("clean", function() {
    return del(["out/**", "package.nls.*.json"]);
});

gulp.task("build", gulp.series("clean", "internal-nls-compile", "add-i18n"));

gulp.task("compile", gulp.series("clean", "internal-compile"));

gulp.task("publish", gulp.series("build", "vsce:publish"));

gulp.task("default", gulp.series('build'));<|endoftext|>


<commit_before>// QA specific gulpfile. Had problems with csscss so haven't put that in yet.

var gulp = require('gulp'),
    cleanhtml = require('gulp-cleanhtml'),
    csslint = require('gulp-csslint'),
    htmlhint = require('gulp-htmlhint'),
    jshint = require('gulp-jshint'),
    notify = require('gulp-notify'),
    plumber = require('gulp-plumber'),
    size = require('gulp-size'),
    uncss = require('gulp-uncss'),
    w3cjs = require('gulp-w3cjs'),
    gulputil = require('gulp-util'),
    stylestats = require('gulp-stylestats-report'),
    clean = require('gulp-clean');

var fs = require('fs'),
    mkdirp = require('mkdirp'),
    runSequence = require('run-sequence');

var reportsDir = './reports/json'

    //Individual Tasks

gulp.task('markymark', function() {
  var jsonReporter = function (file) {
    if (file && file.htmlhint) {
      fs.writeFileSync(reportsDir + '/htmlhint-' + file.path.split('/').pop().replace(/\.[^\.]+$/, '') + '.json', JSON.stringify(file.htmlhint, null, 2));
    }
  };

  return gulp.src('build/*.html')
    .pipe(plumber())
    .pipe(htmlhint())
    .pipe(htmlhint.reporter(jsonReporter))
    .pipe(notify("The Funky Bunch has hinted."));
});

gulp.task('wildstyle', function() {
  mkdirp(reportsDir);

  var jsonReporter = function (file) {
    if (file && file.csslint) {
      fs.writeFileSync(reportsDir + '/csshint-' + file.path.split('/').pop().replace(/\.[^\.]+$/, '') + '.json', JSON.stringify(file.csslint, null, 2));
    }
  };

  return gulp.src('build/css/*.css')
    .pipe(plumber())
    .pipe(csslint())
    .pipe(csslint.reporter(jsonReporter))
    .pipe(notify("All right, all right, all right! CSS busted"));
});

gulp.task('stylestats', function() {
  return gulp.src('build/css/*.css')
    .pipe(stylestats({reportDir: './reports/json'}))
    .pipe(notify("stylestats report generated."));
});

gulp.task('validation', function() {
  return gulp.src('build/*.html')
    .pipe(w3cjs())
    .pipe(notify("Validation Complete!"));
});

gulp.task('uncss', function() {
  return gulp.src('build/css/*.css')
    .pipe(plumber())
    .pipe(uncss({
      html: ['build/index.html']
    }))
    .pipe(gulp.dest('build/linted/css'))
    .pipe(notify('Removed unused styles'));
});

gulp.task('cleanhtml', function() {
  return gulp.src('build/*.html')
    .pipe(plumber())
    .pipe(cleanhtml())
    .pipe(gulp.dest('build/linted'))
    .pipe(notify('Cleaned up html'));
});

gulp.task('size', function() {
  return gulp.src('build')
    .pipe(size(showFiles));
});

gulp.task('jshint', function() {
  var jsonReporter = function (results, data, s2) {
    var filename = results[0].file.split('/').pop().replace(/\.[^\.]+$/, '');
    var output = {
      results: results,
      data: data
    };

    fs.writeFileSync(reportsDir + '/jshint-' + filename + '.json', JSON.stringify(output, null, 2));
  };

  return gulp.src('build/js/*.js')
    .pipe(jshint('build/js/.jshintrc'))
    .pipe(jshint.reporter(jsonReporter))
    .pipe(notify('JS has been hinted'));
});

gulp.task('clean-reports', function () {
  return gulp.src('./reports/json')
    .pipe(clean());
});

gulp.task('reports-index', function (cb) {
  var reports = fs.readdirSync('./reports/json/');
  var output = {
    css: [],
    stylestats: [],
    html: [],
    js: []
  };

  for (var i = reports.length - 1; i >= 0; i--) {
    if (/^csshint/.test(reports[i])) output.css.push(reports[i]);
    if (/^jshint/.test(reports[i])) output.js.push(reports[i]);
    if (/^htmlhint/.test(reports[i])) output.html.push(reports[i]);
    if (/^stylestats/.test(reports[i])) output.stylestats.push(reports[i]);
  };

  fs.writeFileSync(reportsDir + '/index.json', JSON.stringify(output, null, 2));

  cb();
});

gulp.task('generate-reports', function (cb) {
  runSequence('clean-reports', ['jshint', 'wildstyle', 'markymark', 'stylestats'], 'reports-index', cb);
});
<commit_msg>minor formatting fixes.<commit_after>var gulp = require('gulp'),
    cleanhtml = require('gulp-cleanhtml'),
    csslint = require('gulp-csslint'),
    htmlhint = require('gulp-htmlhint'),
    jshint = require('gulp-jshint'),
    notify = require('gulp-notify'),
    plumber = require('gulp-plumber'),
    size = require('gulp-size'),
    uncss = require('gulp-uncss'),
    w3cjs = require('gulp-w3cjs'),
    gulputil = require('gulp-util'),
    stylestats = require('gulp-stylestats-report'),
    clean = require('gulp-clean');

var fs = require('fs'),
    mkdirp = require('mkdirp'),
    runSequence = require('run-sequence');

var reportsDir = './reports/json'

    //Individual Tasks

gulp.task('markymark', function() {
  var jsonReporter = function (file) {
    if (file && file.htmlhint) {
      fs.writeFileSync(reportsDir + '/htmlhint-' + file.path.split('/').pop().replace(/\.[^\.]+$/, '') + '.json', JSON.stringify(file.htmlhint, null, 2));
    }
  };

  return gulp.src('build/*.html')
    .pipe(plumber())
    .pipe(htmlhint())
    .pipe(htmlhint.reporter(jsonReporter))
    .pipe(notify("The Funky Bunch has hinted."));
});

gulp.task('wildstyle', function() {
  mkdirp(reportsDir);

  var jsonReporter = function (file) {
    if (file && file.csslint) {
      fs.writeFileSync(reportsDir + '/csshint-' + file.path.split('/').pop().replace(/\.[^\.]+$/, '') + '.json', JSON.stringify(file.csslint, null, 2));
    }
  };

  return gulp.src('build/css/*.css')
    .pipe(plumber())
    .pipe(csslint())
    .pipe(csslint.reporter(jsonReporter))
    .pipe(notify("All right, all right, all right! CSS busted"));
});

gulp.task('stylestats', function() {
  return gulp.src('build/css/*.css')
    .pipe(stylestats({reportDir: './reports/json'}))
    .pipe(notify("stylestats report generated."));
});

gulp.task('validation', function() {
  return gulp.src('build/*.html')
    .pipe(w3cjs())
    .pipe(notify("Validation Complete!"));
});

gulp.task('uncss', function() {
  return gulp.src('build/css/*.css')
    .pipe(plumber())
    .pipe(uncss({
      html: ['build/index.html']
    }))
    .pipe(gulp.dest('build/linted/css'))
    .pipe(notify('Removed unused styles'));
});

gulp.task('cleanhtml', function() {
  return gulp.src('build/*.html')
    .pipe(plumber())
    .pipe(cleanhtml())
    .pipe(gulp.dest('build/linted'))
    .pipe(notify('Cleaned up html'));
});

gulp.task('size', function() {
  return gulp.src('build')
    .pipe(size(showFiles));
});

gulp.task('jshint', function() {
  var jsonReporter = function (results, data, s2) {
    var filename = results[0].file.split('/').pop().replace(/\.[^\.]+$/, '');
    var output = {
      results: results,
      data: data
    };

    fs.writeFileSync(reportsDir + '/jshint-' + filename + '.json', JSON.stringify(output, null, 2));
  };

  return gulp.src('build/js/*.js')
    .pipe(jshint('build/js/.jshintrc'))
    .pipe(jshint.reporter(jsonReporter))
    .pipe(notify('JS has been hinted'));
});

gulp.task('clean-reports', function () {
  return gulp.src('./reports/json')
    .pipe(clean());
});

gulp.task('reports-index', function (cb) {
  var reports = fs.readdirSync('./reports/json/');
  var output = {
    css: [],
    stylestats: [],
    html: [],
    js: []
  };

  for (var i = reports.length - 1; i >= 0; i--) {
    if (/^csshint/.test(reports[i])) output.css.push(reports[i]);
    if (/^jshint/.test(reports[i])) output.js.push(reports[i]);
    if (/^htmlhint/.test(reports[i])) output.html.push(reports[i]);
    if (/^stylestats/.test(reports[i])) output.stylestats.push(reports[i]);
  };

  fs.writeFileSync(reportsDir + '/index.json', JSON.stringify(output, null, 2));

  cb();
});

gulp.task('generate-reports', function (cb) {
  runSequence('clean-reports', ['jshint', 'wildstyle', 'markymark', 'stylestats'], 'reports-index', cb);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var bowerFiles = require('main-bower-files');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var livereload = require('gulp-livereload');
var jshint = require('gulp-jshint');

// jshint
gulp.task('jshint', function() {
  return gulp.src(['src/js/app.js', 'src/js/**/*.js'])
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
});

// concat js into one min file javascript.min.js
gulp.task('js-min', function() {
  return gulp.src(['src/js/app.js', 'src/js/**/*.js'])
    .pipe(concat('javascript.js'))
    .pipe(gulp.dest('js'))
    .pipe(uglify())
    .pipe(rename('javascript.min.js'))
    .pipe(gulp.dest('js'));
});

// Only Concat files javascript.js
gulp.task('js-concat', function() {
  return gulp.src(['src/js/app.js', 'src/js/**/*.js'])
    .pipe(concat('javascript.js'))
    .pipe(gulp.dest('js'))
});

// All bower dependecies become vendor.min.js
gulp.task('vendor-min', function() {
  return gulp.src(bowerFiles())
    .pipe(concat('vendor.js'))
    .pipe(gulp.dest('js'))
    .pipe(uglify())
    .pipe(rename('vendor.min.js'))
    .pipe(gulp.dest('js'));
});

// the default task
// checks all files and reloads index
gulp.task('default', function() {
  livereload.listen();
  gulp.watch(['src/**/*','src/**/**/*', 'index.html'],
    [
      'jshint',
      'js-concat',
      function() { livereload.reload('index.html'); }
    ]
  );
});

gulp.task('build', ['jshint', 'vendor-min', 'js-concat'])<commit_msg>watch partials folder<commit_after>var gulp = require('gulp');
var bowerFiles = require('main-bower-files');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var livereload = require('gulp-livereload');
var jshint = require('gulp-jshint');

// jshint
gulp.task('jshint', function() {
  return gulp.src(['src/js/app.js', 'src/js/**/*.js'])
    .pipe(jshint())
    .pipe(jshint.reporter('jshint-stylish'))
});

// concat js into one min file javascript.min.js
gulp.task('js-min', function() {
  return gulp.src(['src/js/app.js', 'src/js/**/*.js'])
    .pipe(concat('javascript.js'))
    .pipe(gulp.dest('js'))
    .pipe(uglify())
    .pipe(rename('javascript.min.js'))
    .pipe(gulp.dest('js'));
});

// Only Concat files javascript.js
gulp.task('js-concat', function() {
  return gulp.src(['src/js/app.js', 'src/js/**/*.js'])
    .pipe(concat('javascript.js'))
    .pipe(gulp.dest('js'))
});

// All bower dependecies become vendor.min.js
gulp.task('vendor-min', function() {
  return gulp.src(bowerFiles())
    .pipe(concat('vendor.js'))
    .pipe(gulp.dest('js'))
    .pipe(uglify())
    .pipe(rename('vendor.min.js'))
    .pipe(gulp.dest('js'));
});

// the default task
// checks all files and reloads index
gulp.task('default', function() {
  livereload.listen();
  gulp.watch(['src/**/*','src/**/**/*', 'index.html', 'partials/*'],
    [
      'jshint',
      'js-concat',
      function() { livereload.reload('index.html'); }
    ]
  );
});

gulp.task('build', ['jshint', 'vendor-min', 'js-concat'])<|endoftext|>


<commit_before>/* Dependencies */
var gulp = require('gulp');
var nunjucks = require('gulp-nunjucks');
var htmlmin = require('gulp-htmlmin');
var gulpif = require('gulp-if');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var seq = require('gulp-sequence');
var del = require('del');
var fs = require('fs');
var md = require('markdown').markdown;

/* Import data from files */
var pkgInfo = JSON.parse(fs.readFileSync('./package.json'));
var contents = md.toHTML(fs.readFileSync('./README.md', 'utf-8'));

/* Configuration */
var paths = {
  src: 'src/',
  dist: 'dist/'
};

/* Dist Tasks */
gulp.task('template', function() {
  var opts = {
    globs: [
      '**/*',
      '!styles/**/*',
      '!script/**/*',
      '!images/**/*'
    ],
    src: {
      cwd: paths.src,
      base: paths.src
    },
    nunjucks: {
      site: pkgInfo,
      contents: contents
    },
    htmlmin: {
      removeComments: false,
      collapseWhitespace: true
    }
  };

  return gulp
    .src(opts.globs, opts.src)
    .pipe(nunjucks.compile(opts.nunjucks))
    .pipe(gulpif('*.html', htmlmin(opts.htmlmin)))
    .pipe(gulp.dest(paths.dist));
});

gulp.task('styles', function() {
  var opts = {
    globs: '**/[^_]*.scss',
    src: {
      cwd: paths.src + '/styles',
      base: paths.src
    },
    sass: {
      includePaths: [
        paths.src + '/styles/include/'
      ],
      outputStyle: 'compact',
      errLogToConsole: true
    },
    autoprefixer: {
      remove: false
    }
  };

  return gulp
    .src(opts.globs, opts.src)
    .pipe(sass(opts.sass).on('error', sass.logError))
    .pipe(autoprefixer(opts.autoprefixer))
    .pipe(gulp.dest(paths.dist));
});

gulp.task('clean', function() {
  return del(paths.dist);
});

/* Global tasks */
gulp.task('default', ['template', 'styles']);
<commit_msg>sass output 스타일을 `compressed` 로 변경<commit_after>/* Dependencies */
var gulp = require('gulp');
var nunjucks = require('gulp-nunjucks');
var htmlmin = require('gulp-htmlmin');
var gulpif = require('gulp-if');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var seq = require('gulp-sequence');
var del = require('del');
var fs = require('fs');
var md = require('markdown').markdown;

/* Import data from files */
var pkgInfo = JSON.parse(fs.readFileSync('./package.json'));
var contents = md.toHTML(fs.readFileSync('./README.md', 'utf-8'));

/* Configuration */
var paths = {
  src: 'src/',
  dist: 'dist/'
};

/* Dist Tasks */
gulp.task('template', function() {
  var opts = {
    globs: [
      '**/*',
      '!styles/**/*',
      '!script/**/*',
      '!images/**/*'
    ],
    src: {
      cwd: paths.src,
      base: paths.src
    },
    nunjucks: {
      site: pkgInfo,
      contents: contents
    },
    htmlmin: {
      removeComments: false,
      collapseWhitespace: true
    }
  };

  return gulp
    .src(opts.globs, opts.src)
    .pipe(nunjucks.compile(opts.nunjucks))
    .pipe(gulpif('*.html', htmlmin(opts.htmlmin)))
    .pipe(gulp.dest(paths.dist));
});

gulp.task('styles', function() {
  var opts = {
    globs: '**/[^_]*.scss',
    src: {
      cwd: paths.src + '/styles',
      base: paths.src
    },
    sass: {
      includePaths: [
        paths.src + '/styles/include/'
      ],
      outputStyle: 'compressed',
      errLogToConsole: true
    },
    autoprefixer: {
      remove: false
    }
  };

  return gulp
    .src(opts.globs, opts.src)
    .pipe(sass(opts.sass).on('error', sass.logError))
    .pipe(autoprefixer(opts.autoprefixer))
    .pipe(gulp.dest(paths.dist));
});

gulp.task('clean', function() {
  return del(paths.dist);
});

/* Global tasks */
gulp.task('default', ['template', 'styles']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var pkg = require('./package.json');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var jpegtran = require('imagemin-jpegtran');
var gifsicle = require('imagemin-gifsicle');
var minifyHTML = require('gulp-minify-html');
var fs = require('fs');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cache = require('gulp-cache');
var parallel = require("concurrent-transform");
var concat = require('gulp-concat');

// Set the banner content
var banner = ['/*!\n',
    ' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
    ' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
    ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
    ' */\n',
    ''
].join('');

// Compile LESS files from /less into /css
gulp.task('less', function() {
    return gulp.src('less/grayscale.less')
        .pipe(less())
        .pipe(header(banner, { pkg: pkg }))
        .pipe(gulp.dest('css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

// Minify compiled CSS
// gulp.task('minify-css', ['less'], function() {
//     return gulp.src('css/grayscale.css')
//         .pipe(cleanCSS({ compatibility: 'ie8' }))
//         .pipe(rename({ suffix: '.min' }))
//         .pipe(gulp.dest('css'))
//         .pipe(browserSync.reload({
//             stream: true
//         }))
// });

/**
 * Compile files from sass into _includes then we can use Jekyll includes inline css
 */
gulp.task('styles', function() {
    return gulp.src('css/main.scss')
        .pipe(sass({ includePaths: require('node-bourbon').includePaths }))
        .pipe(concat('styles.css'))
        .pipe(minify({keepBreaks:true}))
        .pipe(gulp.dest('_includes'));
});

// Minify JS
gulp.task('minify-js', function() {
    return gulp.src('js/grayscale.js')
        .pipe(uglify())
        .pipe(header(banner, { pkg: pkg }))
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('js'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

gulp.task('optimize-images', function () {
    return gulp.src(["img/projects/*.jpg", "img/projects/*.png"]) //['img/**/*.jpg', 'img/**/*.jpeg', 'img/**/*.gif', 'img/**/*.png','img/*.jpg', 'img/*.jpeg', 'img/*.gif', 'img/*.png']
        .pipe(parallel(imagemin({
            progressive: true,
            svgoPlugins: [{ removeViewBox: false }],
            use: [pngquant()]
        })))
        // .pipe(imagemin({
        //     optimizationLevel: 5,
        //     progressive: true,
        //     interlaced: true,
        //     svgoPlugins: [{removeViewBox: false}],
        //     use: [pngquant(), jpegtran(), gifsicle()]
        // }))
        //.pipe(cache(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true })))
        .pipe(gulp.dest('img/'));
});

gulp.task('optimize-html', function() {
    return gulp.src('_site/**/*.html')
        .pipe(minifyHTML({
            quotes: true
        }))
        .pipe(replace(/<link href=\"\/css\/main.css\"[^>]*>/, function(s) {
            var style = fs.readFileSync('_site/css/main.css', 'utf8');
            return '<style>\n' + style + '\n</style>';
        }))
        .pipe(gulp.dest('_site/'));
});

// Copy vendor libraries from /node_modules into /vendor
gulp.task('copy', function() {
    gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
        .pipe(gulp.dest('vendor/bootstrap'))

    gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
        .pipe(gulp.dest('vendor/jquery'))

    gulp.src([
            'node_modules/font-awesome/**',
            '!node_modules/font-awesome/**/*.map',
            '!node_modules/font-awesome/.npmignore',
            '!node_modules/font-awesome/*.txt',
            '!node_modules/font-awesome/*.md',
            '!node_modules/font-awesome/*.json'
        ])
        .pipe(gulp.dest('vendor/font-awesome'))
})

// Run everything
gulp.task('default', ['less', 'minify-css', 'minify-js', 'copy', 'optimize-images', 'optimize-html', 'styles']);

// Configure the browserSync task
gulp.task('browserSync', function() {
    browserSync.init({
        server: {
            baseDir: ''
        },
    })
})

// Dev task with browserSync
gulp.task('dev', ['browserSync', 'less', 'minify-css', 'minify-js', 'optimize-images'], function() {
    gulp.watch('less/*.less', ['less']);
    gulp.watch('css/*.css', ['minify-css']);
    gulp.watch('js/*.js', ['minify-js']);
    gulp.watch('img/**', ['optimize-images']);
    // Reloads the browser whenever HTML or JS files change
    gulp.watch('*.html', browserSync.reload);
    //gulp.watch('_data/**', browserSync.reload);
    gulp.watch('js/**/*.js', browserSync.reload);
});
<commit_msg>recommit<commit_after>var gulp = require('gulp');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var pkg = require('./package.json');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var jpegtran = require('imagemin-jpegtran');
var gifsicle = require('imagemin-gifsicle');
var minifyHTML = require('gulp-minify-html');
var fs = require('fs');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cache = require('gulp-cache');
var parallel = require("concurrent-transform");
var concat = require('gulp-concat');

// Set the banner content
var banner = ['/*!\n',
    ' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
    ' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
    ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n',
    ' */\n',
    ''
].join('');

// Compile LESS files from /less into /css
gulp.task('less', function() {
    return gulp.src('less/grayscale.less')
        .pipe(less())
        .pipe(header(banner, { pkg: pkg }))
        .pipe(gulp.dest('css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

// Minify compiled CSS
// gulp.task('minify-css', ['less'], function() {
//     return gulp.src('css/grayscale.css')
//         .pipe(cleanCSS({ compatibility: 'ie8' }))
//         .pipe(rename({ suffix: '.min' }))
//         .pipe(gulp.dest('css'))
//         .pipe(browserSync.reload({
//             stream: true
//         }))
// });

/**
 * Compile files from sass into _includes then we can use Jekyll includes inline css
 */
gulp.task('styles', function() {
    return gulp.src('css/main.scss')
        .pipe(sass({ includePaths: require('node-bourbon').includePaths }))
        .pipe(concat('styles.css'))
        .pipe(minify({keepBreaks:true}))
        .pipe(gulp.dest('_includes'));
});

// Minify JS
gulp.task('minify-js', function() {
    return gulp.src('js/grayscale.js')
        .pipe(uglify())
        .pipe(header(banner, { pkg: pkg }))
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('js'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

gulp.task('optimize-images', function () {
    return gulp.src(["img/projects/*.jpg", "img/projects/*.png"]) //['img/**/*.jpg', 'img/**/*.jpeg', 'img/**/*.gif', 'img/**/*.png','img/*.jpg', 'img/*.jpeg', 'img/*.gif', 'img/*.png']
        .pipe(imagemin({
            optimizationLevel: 5,
            progressive: true,
            interlaced: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant(), jpegtran(), gifsicle()]
        }))
        .pipe(parallel(imagemin({
            progressive: true,
            svgoPlugins: [{ removeViewBox: false }],
            use: [pngquant()]
        })))
        // .pipe(cache(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true })))
        .pipe(gulp.dest('img/'));
});

gulp.task('optimize-html', function() {
    return gulp.src('_site/**/*.html')
        .pipe(minifyHTML({
            quotes: true
        }))
        .pipe(replace(/<link href=\"\/css\/main.css\"[^>]*>/, function(s) {
            var style = fs.readFileSync('_site/css/main.css', 'utf8');
            return '<style>\n' + style + '\n</style>';
        }))
        .pipe(gulp.dest('_site/'));
});

// Copy vendor libraries from /node_modules into /vendor
gulp.task('copy', function() {
    gulp.src(['node_modules/bootstrap/dist/**/*', '!**/npm.js', '!**/bootstrap-theme.*', '!**/*.map'])
        .pipe(gulp.dest('vendor/bootstrap'))

    gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
        .pipe(gulp.dest('vendor/jquery'))

    gulp.src([
            'node_modules/font-awesome/**',
            '!node_modules/font-awesome/**/*.map',
            '!node_modules/font-awesome/.npmignore',
            '!node_modules/font-awesome/*.txt',
            '!node_modules/font-awesome/*.md',
            '!node_modules/font-awesome/*.json'
        ])
        .pipe(gulp.dest('vendor/font-awesome'))
})

// Run everything
gulp.task('default', ['less', 'minify-css', 'minify-js', 'copy', 'optimize-images', 'optimize-html', 'styles']);

// Configure the browserSync task
gulp.task('browserSync', function() {
    browserSync.init({
        server: {
            baseDir: ''
        },
    })
})

// Dev task with browserSync
gulp.task('dev', ['browserSync', 'less', 'minify-css', 'minify-js', 'optimize-images'], function() {
    gulp.watch('less/*.less', ['less']);
    gulp.watch('css/*.css', ['minify-css']);
    gulp.watch('js/*.js', ['minify-js']);
    gulp.watch('img/**', ['optimize-images']);
    // Reloads the browser whenever HTML or JS files change
    gulp.watch('*.html', browserSync.reload);
    //gulp.watch('_data/**', browserSync.reload);
    gulp.watch('js/**/*.js', browserSync.reload);
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    path = require('path'),
    less = require('gulp-less');
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    cleancss = require('gulp-cleancss'),
    autoprefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
    apBrowsers = {
        browsers: ['ie >= 9', 'Firefox >= 24', 'Chrome >= 26', 'iOS >= 5', 'Safari >= 6', 'Android > 2.3']
    },
    destDir = './build';

var paths = {
    mainCss: [
        'src/less/calendula.less',
        'src/less/calendula__tooltip.less'
    ],
    mainJs: [
        'src/js/start.js',

        'src/js/main.js',
        'src/js/ext.js',
        'src/js/lib/*.js',
        'src/js/ext/*.js',

        'src/js/end.js'
    ],
    prodJsLocales: [
        'src/js/locale/*.js'
    ],
    prodJsHolidays: [
        'src/js/holiday/*.js'
    ],
    prodCssThemes: [
        'src/less/calendula.theme.*.less'
    ]
};

paths.devJs = paths.mainJs.concat('src/js/locale/*.js', 'src/js/holiday/*.js');
paths.prodJsBase = paths.mainJs;
paths.prodJsAll = paths.mainJs.concat('src/js/locale/calendula.locale.*.js', 'src/js/locale/calendula.holiday.*.js');

paths.devCss = paths.mainCss.concat('src/less/calendula.theme.*.less');
paths.prodCssAll = paths.mainCss.concat('src/less/calendula.theme.*.less');

var jsTasks = ['devJs', 'prodJsBase', 'prodJsAll', 'prodJsLocales', 'prodJsHolidays'],
    cssTasks = ['devCss', 'prodCssBase', 'prodCssAll', 'prodCssThemes'],
    allTasks = [].concat(cssTasks, jsTasks);

gulp.task('devJs', function() {
    return gulp.src(paths.devJs)
        .pipe(concat('calendula.dev.js'))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsBase', function() {
    return gulp.src(paths.prodJsBase)
        .pipe(concat('calendula.base.js'))
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsAll', function() {
    return gulp.src(paths.prodJsAll)
        .pipe(concat('calendula.all.js'))
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsLocales', function() {
    return gulp.src(paths.prodJsLocales)
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsHolidays', function() {
    return gulp.src(paths.prodJsHolidays)
        .pipe(uglify())
        .pipe(gulp.dest(destDir));
});

gulp.task('devCss', function() {
    return gulp.src(paths.devCss)
        .pipe(concat('calendula.dev.css'))
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodCssBase', function() {
    return gulp.src(paths.mainCss)
        .pipe(concat('calendula.base.css'))
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(cleancss({keepBreaks: false}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodCssAll', function() {
    return gulp.src(paths.prodCssAll)
        .pipe(concat('calendula.all.css'))
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(cleancss({keepBreaks: false}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodCssThemes', function() {
    return gulp.src(paths.prodCssThemes)
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(cleancss({keepBreaks: false}))
        .pipe(gulp.dest(destDir));
});

gulp.task('watch', function() {
    gulp.watch('src/js/**/*', jsTasks);
    gulp.watch('src/less/**/*', cssTasks);
});

gulp.task('default', allTasks);
<commit_msg>Fix codestyle<commit_after>var gulp = require('gulp'),
    path = require('path'),
    less = require('gulp-less');
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    cleancss = require('gulp-cleancss'),
    autoprefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
    apBrowsers = {
        browsers: ['ie >= 9', 'Firefox >= 24', 'Chrome >= 26', 'iOS >= 5', 'Safari >= 6', 'Android > 2.3']
    },
    destDir = './build';

var paths = {
    mainCss: [
        'src/less/calendula.less',
        'src/less/calendula__tooltip.less'
    ],
    mainJs: [
        'src/js/start.js',

        'src/js/main.js',
        'src/js/ext.js',
        'src/js/lib/*.js',
        'src/js/ext/*.js',

        'src/js/end.js'
    ],
    prodJsLocales: [
        'src/js/locale/*.js'
    ],
    prodJsHolidays: [
        'src/js/holiday/*.js'
    ],
    prodCssThemes: [
        'src/less/calendula.theme.*.less'
    ]
};

paths.devJs = paths.mainJs.concat('src/js/locale/*.js', 'src/js/holiday/*.js');
paths.prodJsBase = paths.mainJs;
paths.prodJsAll = paths.mainJs.concat('src/js/locale/calendula.locale.*.js', 'src/js/locale/calendula.holiday.*.js');

paths.devCss = paths.mainCss.concat('src/less/calendula.theme.*.less');
paths.prodCssAll = paths.mainCss.concat('src/less/calendula.theme.*.less');

var jsTasks = ['devJs', 'prodJsBase', 'prodJsAll', 'prodJsLocales', 'prodJsHolidays'],
    cssTasks = ['devCss', 'prodCssBase', 'prodCssAll', 'prodCssThemes'],
    allTasks = [].concat(cssTasks, jsTasks);

gulp.task('devJs', function() {
    return gulp.src(paths.devJs)
        .pipe(concat('calendula.dev.js'))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsBase', function() {
    return gulp.src(paths.prodJsBase)
        .pipe(concat('calendula.base.js'))
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsAll', function() {
    return gulp.src(paths.prodJsAll)
        .pipe(concat('calendula.all.js'))
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsLocales', function() {
    return gulp.src(paths.prodJsLocales)
        .pipe(uglify({preserveComments: 'some'}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodJsHolidays', function() {
    return gulp.src(paths.prodJsHolidays)
        .pipe(uglify())
        .pipe(gulp.dest(destDir));
});

gulp.task('devCss', function() {
    return gulp.src(paths.devCss)
        .pipe(concat('calendula.dev.css'))
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodCssBase', function() {
    return gulp.src(paths.mainCss)
        .pipe(concat('calendula.base.css'))
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(cleancss({keepBreaks: false}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodCssAll', function() {
    return gulp.src(paths.prodCssAll)
        .pipe(concat('calendula.all.css'))
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(cleancss({keepBreaks: false}))
        .pipe(gulp.dest(destDir));
});

gulp.task('prodCssThemes', function() {
    return gulp.src(paths.prodCssThemes)
        .pipe(less())
        .pipe(autoprefixer(apBrowsers))
        .pipe(cleancss({keepBreaks: false}))
        .pipe(gulp.dest(destDir));
});

gulp.task('watch', function() {
    gulp.watch('src/js/**/*', jsTasks);
    gulp.watch('src/less/**/*', cssTasks);
});

gulp.task('default', allTasks);
<|endoftext|>


<commit_before>/**
 *
 *  Web Starter Kit
 *  Copyright 2014 Google Inc. All rights reserved.
 *
 *  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
 *
 */

'use strict';

// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;

// Clean Output Directory
gulp.task('clean', del.bind(null, ['./index.js', './assertRank.js', './specs.js']));

gulp.task('es6', ['clean'], function () {
  return gulp.src(['./src/**/*.js'])
    .pipe($.sourcemaps.init({loadMaps: true}))
    .pipe($['6to5']()).on('error', console.error.bind(console))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('.'))
    .pipe($.size({title: 'es6'}))
})

gulp.task('browserify', ['es6'], function () {
  return gulp.src(['./specs.js'])
    .pipe($.browserify({debug: true}))
    .pipe(gulp.dest('.'))
    .pipe($.size({title: 'browserify'}))
})

// Watch Files For Changes & Reload
gulp.task('serve', ['browserify'], function () {
  browserSync({
    notify: false, browser: 'skip', ghostMode: false,

    // Customize the BrowserSync console logging prefix
    logPrefix: 'WSK',
    port: 3010,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: ['.', 'src']
  });

  gulp.watch(['gulpfile.js'], process.exit)
  gulp.watch(['./src/**/*.{js,html}'], ['browserify', reload]);
});

gulp.task('default', ['es6'])

// Load custom tasks from the `tasks` directory
// try { require('require-dir')('tasks'); } catch (err) { console.error(err); }
<commit_msg>removed sourcemaps<commit_after>/**
 *
 *  Web Starter Kit
 *  Copyright 2014 Google Inc. All rights reserved.
 *
 *  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
 *
 */

'use strict';

// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;

// Clean Output Directory
gulp.task('clean', del.bind(null, ['./index.js', './assertRank.js', './specs.js']));

gulp.task('es6', ['clean'], function () {
  return gulp.src(['./src/**/*.js'])
    .pipe($.sourcemaps.init({loadMaps: true}))
    .pipe($['6to5']()).on('error', console.error.bind(console))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('.'))
    .pipe($.size({title: 'es6'}))
})

gulp.task('browserify', ['es6'], function () {
  return gulp.src(['./specs.js'])
    .pipe($.browserify({debug: false}))
    .pipe(gulp.dest('.'))
    .pipe($.size({title: 'browserify'}))
})

// Watch Files For Changes & Reload
gulp.task('serve', ['browserify'], function () {
  browserSync({
    notify: false, browser: 'skip', ghostMode: false,

    // Customize the BrowserSync console logging prefix
    logPrefix: 'WSK',
    port: 3010,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: ['.', 'src']
  });

  gulp.watch(['gulpfile.js'], process.exit)
  gulp.watch(['./src/**/*.{js,html}'], ['browserify', reload]);
});

gulp.task('default', ['es6'])

// Load custom tasks from the `tasks` directory
// try { require('require-dir')('tasks'); } catch (err) { console.error(err); }
<|endoftext|>