GithubHelp home page GithubHelp logo

tim-task's Introduction

tim-task

A simple build system I created for git-browser

Here is an example build recipe from git-browser.

#!/usr/bin/env node
var T = require('tim-task');
var path = require('path');

// Override paths using environment variables
var WEBDIR = process.env.WEBDIR || "build/web";
var MOZDIR = process.env.MOZDIR || "build/moz";
var CHROMEDIR = process.env.CHROMEDIR || "build/chrome";
var WEBOSDIR = process.env.WEBOSDIR || "build/webos";
var MOZZIP = MOZDIR + "-app.zip";
var CHROMEZIP = CHROMEDIR + "-app.zip";
var IPK = "build/com.creationix.git-browser_0.0.1_all.ipk";

T("code", ["web", "moz", "chrome"]);

T("all", ["code", "moz-zip", "chrome-zip"]);

function base(bootstrap, targetDir) {
  return T.parallel(
    T.copy("res", targetDir),
    T.newer("src", /\.less$/, targetDir + "/style.css",
      T.lessc("src/" + bootstrap + ".less", targetDir + "/style.css")
    ),
    T.build("src/" + bootstrap + ".js", targetDir + "/app.js")
  );
}
function zipFile(zip, dir) {
  return T.serial(
    T.parallel(
      T.rmrf(zip),
      T.mkdirp(path.dirname(zip))
    ),
    T.execFile("zip", ["-o", "-r", path.relative(dir, zip), '.'], {cwd: dir})
  );
}

T("web", T.parallel(
  T.copy("src/server.js", WEBDIR + "/server.js"),
  base("web", WEBDIR)
));

T("webos", T.parallel(
  base("webos", WEBOSDIR),
  T.copy("src/appinfo.json", WEBOSDIR + "/appinfo.json")
));

T("webos", T.parallel(
  base("webos", WEBOSDIR),
  T.copy("src/appinfo.json", WEBOSDIR + "/appinfo.json")
));

T("webos-ipk", ["webos"], T.newer(WEBOSDIR, /.*/, IPK,
  T.execFile("palm-package", [path.relative("build", WEBOSDIR)], {cwd:"build"})
));

T("webos-install", ["webos-ipk"],
  T.execFile("palm-install", [IPK], {})
);

T("webos-run", ["webos-install"],
  T.execFile("palm-launch", ["com.creationix.git-browser"], {})
);

T("moz", T.parallel(
  base("moz", MOZDIR),
  T.copy("src/manifest.webapp", MOZDIR + "/manifest.webapp")
));

T("moz-zip", ["moz"], zipFile(MOZZIP, MOZDIR));

T("chrome", T.parallel(
  base("chrome", CHROMEDIR),
  T.copy("src/manifest.json", CHROMEDIR + "/manifest.json"),
  T.copy("src/background.js", CHROMEDIR + "/background.js")
));

T("chrome-zip", ["chrome"], zipFile(CHROMEZIP, CHROMEDIR));

T("clean", T.rmrf("build"));

T.execute(T.run, process.argv.slice(2), function (err) {
  if (err) {
    console.error(err.stack || err);
    process.exit(-1);
  }
  // console.log("Done");
});

tim-task's People

Contributors

creationix avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.