From e1e681076211fe8799e1090f47337b5a146d431b Mon Sep 17 00:00:00 2001 From: Thomas Taylor Date: Mon, 16 Oct 2017 18:07:46 +0100 Subject: [PATCH] Add basic support for require --- js/exports.js | 18 ++++++++++++++++++ package.json | 1 + 2 files changed, 19 insertions(+) create mode 100644 js/exports.js diff --git a/js/exports.js b/js/exports.js new file mode 100644 index 0000000..886e4b8 --- /dev/null +++ b/js/exports.js @@ -0,0 +1,18 @@ +var fs = require('fs'); + +var exports = {}; + +['build','serve'].forEach(function(name) { + exports[name] = function(args, cb) { + if(typeof args === 'function') { + cb = args; + args = {}; + } + if(args.dir && fs.existsSync(args.dir)) { + process.env.SITE_SRC = args.dir; + } + require(`../bin/${name}`)(args, cb); + } +}); + +module.exports = exports; diff --git a/package.json b/package.json index 112e0af..8a9556d 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "bin": { "ss": "index.js" }, + "main": "js/exports.js", "siteSrc": "/Users/tom/Projects/tomtaylor.name/main", "templateDefaults": { "container": "page.html",