Updated markoc to allow custom app module paths and to use the marko module installed in the project

This commit is contained in:
Patrick Steele-Idem 2014-11-12 16:46:47 -07:00
parent 490361e2b3
commit 40ae3888e0
2 changed files with 105 additions and 71 deletions

View File

@ -1,11 +1,32 @@
var markoCompiler = require('../compiler');
var fs = require('fs');
var nodePath = require('path');
var Minimatch = require('minimatch').Minimatch;
var cwd = process.cwd();
var resolveFrom = require('resolve-from');
// Try to use the Marko compiler installed with the project
var markoCompilerPath;
try {
markoCompilerPath = resolveFrom(process.cwd(), 'marko/compiler');
} catch(e) {}
var markoCompiler;
if (markoCompilerPath) {
markoCompiler = require(markoCompilerPath);
} else {
markoCompiler = require('../compiler');
}
var Minimatch = require('minimatch').Minimatch;
var appModulePath = require('app-module-path');
require('raptor-polyfill/string/startsWith');
require('raptor-polyfill/string/endsWith');
markoCompiler.defaultOptions.checkUpToDate = false;
var mmOptions = {
matchBase: true,
dot: true,
@ -34,6 +55,10 @@ var args = require('raptor-args').createParser({
'--clean -c': {
type: 'boolean',
description: 'Clean all of the *.marko.js files'
},
'--paths -p': {
type: 'string[]',
description: 'Additional directories to add to the Node.js module search path'
}
})
.usage('Usage: $0 <pattern> [options]')
@ -65,6 +90,13 @@ var args = require('raptor-args').createParser({
.parse();
var paths = args.paths;
if (paths && paths.length) {
paths.forEach(function(path) {
appModulePath.addPath(nodePath.resolve(cwd, path));
});
}
var ignoreRules = args.ignore;
if (!ignoreRules) {
@ -77,7 +109,7 @@ ignoreRules = ignoreRules.filter(function (s) {
});
ignoreRules = ignoreRules.map(function (pattern) {
return new Minimatch(pattern, mmOptions);
});
@ -93,9 +125,9 @@ function isIgnored(path, dir, stat) {
var ignoreRulesLength = ignoreRules.length;
for (var i=0; i<ignoreRulesLength; i++) {
var rule = ignoreRules[i];
var match = rule.match(path);
if (!match && stat && stat.isDirectory()) {
try {
stat = fs.statSync(path);
@ -103,9 +135,9 @@ function isIgnored(path, dir, stat) {
if (stat && stat.isDirectory()) {
match = rule.match(path + '/');
}
}
}
if (match) {
if (rule.negate) {
@ -149,7 +181,7 @@ function walk(files, options, done) {
} else {
done(null);
}
}
}
};
@ -176,7 +208,7 @@ function walk(files, options, done) {
doWalk(file);
} else {
fileCallback(file, context);
}
}
}
context.endAsync();
@ -221,7 +253,7 @@ if (args.clean) {
context.endAsync();
});
}
}
},
@ -231,7 +263,7 @@ if (args.clean) {
} else {
console.log('Deleted ' + deleteCount + ' file(s)');
}
});
} else {
@ -303,7 +335,7 @@ if (args.clean) {
} else {
console.log('Compiled ' + compileCount + ' templates(s)');
}
});
}
}
}

View File

@ -1,59 +1,61 @@
{
"name": "marko",
"description": "Marko is an extensible, streaming, asynchronous, high performance, HTML-based templating language that can be used in Node.js or in the browser.",
"keywords": [
"templating",
"template",
"async",
"streaming"
],
"repository": {
"type": "git",
"url": "https://github.com/raptorjs/marko.git"
},
"scripts": {
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/"
},
"author": "Patrick Steele-Idem <pnidem@gmail.com>",
"maintainers": [
"Patrick Steele-Idem <pnidem@gmail.com>"
],
"dependencies": {
"async-writer": "^1.1.2",
"char-props": "~0.1.5",
"events": "^1.0.2",
"htmlparser2": "^3.7.2",
"marko-async": "^1.1.0",
"marko-layout": "^1.1.0",
"minimatch": "^0.2.14",
"property-handlers": "^1.0.0",
"raptor-args": "^1.0.0",
"raptor-json": "^1.0.1",
"raptor-logging": "^1.0.1",
"raptor-modules": "^1.0.5",
"raptor-polyfill": "^1.0.0",
"raptor-promises": "^1.0.1",
"raptor-regexp": "^1.0.0",
"raptor-strings": "^1.0.0",
"raptor-util": "^1.0.0",
"sax": "^0.6.0"
},
"devDependencies": {
"chai": "~1.8.1",
"dustjs-linkedin": "^2.3.4",
"jshint": "^2.5.0",
"mocha": "~1.15.1",
"raptor-cache": "^1.1.1",
"raptor-data-providers": "^1.0.1-beta",
"through": "^2.3.4"
},
"license": "Apache License v2.0",
"bin": {
"markoc": "bin/markoc"
},
"main": "runtime/marko-runtime.js",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"version": "1.3.8"
}
"name": "marko",
"description": "Marko is an extensible, streaming, asynchronous, high performance, HTML-based templating language that can be used in Node.js or in the browser.",
"keywords": [
"templating",
"template",
"async",
"streaming"
],
"repository": {
"type": "git",
"url": "https://github.com/raptorjs/marko.git"
},
"scripts": {
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/"
},
"author": "Patrick Steele-Idem <pnidem@gmail.com>",
"maintainers": [
"Patrick Steele-Idem <pnidem@gmail.com>"
],
"dependencies": {
"app-module-path": "^1.0.0",
"async-writer": "^1.1.2",
"char-props": "~0.1.5",
"events": "^1.0.2",
"htmlparser2": "^3.7.2",
"marko-async": "^1.1.0",
"marko-layout": "^1.1.0",
"minimatch": "^0.2.14",
"property-handlers": "^1.0.0",
"raptor-args": "^1.0.0",
"raptor-json": "^1.0.1",
"raptor-logging": "^1.0.1",
"raptor-modules": "^1.0.5",
"raptor-polyfill": "^1.0.0",
"raptor-promises": "^1.0.1",
"raptor-regexp": "^1.0.0",
"raptor-strings": "^1.0.0",
"raptor-util": "^1.0.0",
"resolve-from": "^1.0.0",
"sax": "^0.6.0"
},
"devDependencies": {
"chai": "~1.8.1",
"dustjs-linkedin": "^2.3.4",
"jshint": "^2.5.0",
"mocha": "~1.15.1",
"raptor-cache": "^1.1.1",
"raptor-data-providers": "^1.0.1-beta",
"through": "^2.3.4"
},
"license": "Apache License v2.0",
"bin": {
"markoc": "bin/markoc"
},
"main": "runtime/marko-runtime.js",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"version": "1.3.8"
}