Skip to content

Commit

Permalink
Adding recursive watching and output path option
Browse files Browse the repository at this point in the history
Adding recursive watching for directory and the output path option which is relative to each file.
  • Loading branch information
unknown authored and unknown committed Aug 18, 2015
1 parent 0634a55 commit da627a4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 30 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var version = '0.0.4';
var jade = require('jade');
var program = require('commander');
var fs = require('fs');
var read = require('fs-readdir-recursive');
var path = require('path');
var clc = require('cli-color');
var pd = require('pretty-data').pd;
Expand All @@ -16,10 +17,12 @@ program
.version(version)
.option('-e, --extension [extension]', 'output filename extension (default: html)', 'html')
.option('-b, --beautify', 'beautify output')
.option('-o, --out [out]', 'relative output path for each file')
.parse(process.argv);


fs.readdir(".", function (err, files) {
var files = read('.');
(function (err, files) {
if (err) { console.log(err); return; }
var jadeFiles = [];
var i;
Expand All @@ -36,7 +39,7 @@ fs.readdir(".", function (err, files) {
if (!jadefilename) { return; }
fs.readFile(jadefilename, function (err, data) {
if (err) { console.log(err); return; }
var outputfilename = path.basename(jadefilename, ".jade")+"."+program.extension;
var outputfilename = path.dirname(jadefilename) + '/' + program.out + path.basename(jadefilename, ".jade") + "." + program.extension;
var time = new Date();
var compliedData;
try {
Expand Down Expand Up @@ -69,6 +72,6 @@ fs.readdir(".", function (err, files) {
}

console.log("watching", jadeFiles.length, "jade files for changes.", notice("(jadewatch "+version+")"));
});
})(!files, files);

// var name = path.basename(p, ".jade")
87 changes: 60 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
{
"name":"jadewatch",
"description":"jade folder watcher",
"version":"0.0.4",
"homepage":"http://github.com/rc1/jadewatch",
"repository":"git://github.com/rc1/jadewatch.git",
"author":"Ross Cairns <io@theworkers.net> (http://theworkers.net/)",
"main":"./index.js",
"preferGlobal":"true",
"bin":{
"jadewatch":"./bin/jadewatch"
},
"dependencies":{
"jade":"*",
"commander":"*",
"cli-color":"*",
"pretty-data":"0.30.3"
},
"engines":{
"node":">= 0.6.14"
},
"licenses":[
{
"type":"MIT",
"url":"http://github.com/rc1/jadewatch/raw/master/LICENSE"
}
]
}
"name": "jadewatch",
"description": "jade folder watcher",
"version": "0.0.4",
"homepage": "http://github.com/rc1/jadewatch",
"repository": {
"type": "git",
"url": "git://github.com/rc1/jadewatch.git"
},
"author": {
"name": "Ross Cairns",
"email": "io@theworkers.net",
"url": "http://theworkers.net/"
},
"main": "./index.js",
"preferGlobal": "true",
"bin": {
"jadewatch": "./bin/jadewatch"
},
"dependencies": {
"jade": "*",
"commander": "*",
"cli-color": "*",
"fs-readdir-recursive": "*",
"pretty-data": "0.30.3"
},
"engines": {
"node": ">= 0.6.14"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/rc1/jadewatch/raw/master/LICENSE"
}
],
"_npmUser": {
"name": "rc1",
"email": "ross@electricglen.com"
},
"_id": "jadewatch@0.0.4",
"devDependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.13",
"_nodeVersion": "v0.6.14",
"_defaultsLoaded": true,
"dist": {
"shasum": "197b0221e606dedc4e670530cc1078a2aed265e5",
"tarball": "http://registry.npmjs.org/jadewatch/-/jadewatch-0.0.4.tgz"
},
"maintainers": [
{
"name": "rc1",
"email": "ross@electricglen.com"
}
],
"directories": {},
"_shasum": "197b0221e606dedc4e670530cc1078a2aed265e5",
"_resolved": "https://registry.npmjs.org/jadewatch/-/jadewatch-0.0.4.tgz",
"_from": "jadewatch@*"
}

0 comments on commit da627a4

Please sign in to comment.