Skip to content
Permalink
Browse files

Pass eslint internally.

  • Loading branch information...
ryan-roemer committed Oct 24, 2015
1 parent 266ecf3 commit ec28e99fe48c03bdab0af2fb07f1230830b6f143
Showing with 47 additions and 11 deletions.
  1. +3 −0 .eslintrc-server
  2. +2 −2 bin/builder.js
  3. +10 −3 lib/environment.js
  4. +2 −2 lib/log.js
  5. +2 −2 lib/runner.js
  6. +5 −2 lib/scripts.js
  7. +3 −0 lib/task.js
  8. +20 −0 package.json
@@ -0,0 +1,3 @@
---
extends:
- "defaults/configurations/walmart/es5-node"
@@ -1,6 +1,5 @@
#!/usr/bin/env node

var log = require("../lib/log");
"use strict";

// Set up environment
var Environment = require("../lib/environment");
@@ -15,5 +14,6 @@ var task = new Task();

// Run the task
task.execute(env, function (err) {
/*eslint-disable no-process-exit*/
process.exit(err ? err.code || 1 : 0);
});
@@ -14,12 +14,15 @@ var DELIM = process.platform.indexOf("win") === 0 ? ";" : ":";

// Node binary directories.
var CWD_BIN = path.join(process.cwd(), "node_modules/.bin");
var ARCHETYPE_BIN = path.join(__dirname, "../../builder-react-component/node_modules/.bin"); // TODO: ARCHETYPE
// TODO: EXTRACT TO ARCHETYPE INFERENCE
var ARCHETYPE_BIN = path.join(__dirname,
"../../builder-react-component/node_modules/.bin");

/**
* Environment wrapper.
*
* @param {Object} env Environment object to mutate (Default `process.env`)
* @returns {void}
*/
var Environment = module.exports = function (env) {
this.env = env || process.env;
@@ -40,11 +43,13 @@ var Environment = module.exports = function (env) {
* @returns {String} `PATH` environment variable (post-mutation)
*/
Environment.prototype.updatePath = function () {
return this.env.PATH = (this.env.PATH || "")
this.env.PATH = (this.env.PATH || "")
.split(DELIM)
.filter(function (x) { return x; }) // Remove empty strings
.concat([CWD_BIN, ARCHETYPE_BIN])
.join(DELIM);

return this.env.PATH;
};

/**
@@ -59,9 +64,11 @@ Environment.prototype.updatePath = function () {
Environment.prototype.updateNodePath = function () {
var paths = Array.prototype.slice.call(arguments);

return this.env.NODE_PATH = (this.env.NODE_PATH || "")
this.env.NODE_PATH = (this.env.NODE_PATH || "")
.split(DELIM)
.filter(function (x) { return x; }) // Remove empty strings
.concat(paths)
.join(DELIM);

return this.env.NODE_PATH;
};
@@ -8,14 +8,14 @@ var cons = console;
// Wrap "type".
var wrapType = function (type) {
return "[builder" + (type ? ":" + type : "") + "]";
}
};

/**
* A super-small logger.
*/
module.exports = {
info: function (type, msg) {
cons.log([chalk.green(wrapType(type)), msg].join(" "))
cons.log([chalk.green(wrapType(type)), msg].join(" "));
},

error: function (type, msg) {
@@ -6,7 +6,7 @@ var log = require("../lib/log");

// Process runner.
var run = function (env, cmd, callback) {
log.info("proc:start", cmd)
log.info("proc:start", cmd);
var proc = exec(cmd, {
env: env.env
}, function (err) {
@@ -17,7 +17,7 @@ var run = function (env, cmd, callback) {
log.error("proc:error", "Code: " + code + ", Command: " + cmd);
}

log.info("proc:end:" + code, cmd)
log.info("proc:end:" + code, cmd);
callback(err);
});

@@ -5,12 +5,15 @@ var chalk = require("chalk");
var _ = require("lodash");

// Load local `package.json`.
/*eslint-disable global-require*/
// TODO: Protect on import error.
var CWD_PKG = (require(path.join(process.cwd(), "package.json")) || {}).scripts || {};
// TODO: HACK -- Import archetypes
var ARCH_PKG = (require(path.join(process.cwd(), "node_modules/builder-react-component/package.json")) || {}).scripts || {};
var ARCH_PKG = (require(path.join(process.cwd(),
"node_modules/builder-react-component/package.json")) || {}).scripts || {};
/*eslint-enable global-require*/

var scripts = module.exports = {
module.exports = {
cwd: CWD_PKG,
archetype: ARCH_PKG,

@@ -11,6 +11,7 @@ var log = require("./log");
* Task wrapper.
*
* @param {Array} argv Arguments array (Default: `process.argv`)
* @returns {void}
*/
var Task = module.exports = function (argv) {
argv = argv || process.argv;
@@ -84,7 +85,9 @@ Task.prototype.getCommand = function (cmd) {
/**
* Execute task or tasks.
*
* @param {Object} env Environment object
* @param {Function} callback Callback function `(err)`
* @returns {void}
*/
Task.prototype.execute = function (env, callback) {
if (!env) {
@@ -2,12 +2,32 @@
"name": "builder",
"version": "0.0.1",
"description": "An NPM-based task runner",
"repository": {
"type": "git",
"url": "https://github.com/FormidableLabs/builder.git"
},
"author": "Ryan Roemer <ryan.roemer@formidablelabs.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/FormidableLabs/builder/issues"
},
"homepage": "https://github.com/FormidableLabs/builder",
"scripts": {
"builder:lint-server": "eslint --color -c .eslintrc-server lib bin",
"builder:lint": "npm run builder:lint-server",
"builder:check": "npm run builder:lint"
},
"bin": {
"builder": "bin/builder.js"
},
"dependencies": {
"async": "^1.4.2",
"chalk": "^1.1.1",
"lodash": "^3.10.1"
},
"devDependencies": {
"eslint": "^1.7.3",
"eslint-config-defaults": "^7.0.1",
"eslint-plugin-filenames": "^0.1.2"
}
}

0 comments on commit ec28e99

Please sign in to comment.
You can’t perform that action at this time.