——对咖啡字典编辑的监视指令没有工作,没有工作。 如何确定?
(目前需要在Heroku进行部署的第0.4.7号)
——对咖啡字典编辑的监视指令没有工作,没有工作。 如何确定?
(目前需要在Heroku进行部署的第0.4.7号)
无。 Node.js 0.4.7中的观察方法。 用以下文字取代198线的监视功能:
watch = function(source, base) {
return fs.stat(source, function(err, prevStats) {
if (err) throw err;
return fs.watchFile(source, function(curr, prev) {
return fs.stat(source, function(err, stats) {
if (err) throw err;
if (stats.size === prevStats.size && stats.mtime.getTime() === prevStats.mtime.getTime()) {
return;
}
prevStats = stats;
return fs.readFile(source, function(err, code) {
if (err) throw err;
return compileScript(source, code.toString(), base);
});
});
});
});
};
如果您升至0.6,可尝试Jitter。 它的单一用途指挥线效用是<代码>coffee -cw之前使用的。 咖啡厅 1.1.3. 此外,它有一些额外的东西,如汇编失败时的“Grownl”通知。
Here s a watchscript I wrote after having same experience with coffeescript -w option not working. It finds and watches .coffee, .less, .jade files for change and triggers their corresponding compilers in response. Generates colored output for easy detection of when the compilation failed.
/*
* Tested on node 0.6, Ubuntu
*/
#!/usr/bin/node
COLOR_GREEN=" 33[01;32m"
COLOR_RED=" 33[01;31m"
COLOR_YELLOW=" 33[01;33m"
COLOR_BLUE=" 33[01;34m"
COLOR_NORMAL=" 33[00m"
var fs = require( fs );
var coffeescript, jade, less;
try {
coffeescript = require( /usr/lib/node_modules/coffee-script ); // after npm -g install coffee-script
} catch(e) {
console.log(COLOR_RED,String(e),COLOR_NORMAL);
}
try {
jade = require( /usr/lib/node_modules/jade ); // after npm -g install jade
} catch(e) {
console.log(COLOR_RED,String(e),COLOR_NORMAL);
}
try {
less = require( /usr/lib/node_modules/less ); // after npm -g install less
} catch(e) {
console.log(COLOR_RED,String(e),COLOR_NORMAL);
}
console.log(
Watch Support ,
(coffeescript ? COLOR_GREEN : COLOR_RED), coffeescript ,COLOR_NORMAL,
(jade ? COLOR_GREEN : COLOR_RED), jade ,COLOR_NORMAL,
(less ? COLOR_GREEN : COLOR_RED), less ,COLOR_NORMAL
);
var compile = function (fname) {
var source = fs.readFileSync(fname).toString();
try {
if(/.jade$/.test(fname)) {
var html = jade.compile(source,{pretty:true})();
var htmlfname = fname.replace(/.jade$/, .html );
fs.writeFileSync(htmlfname, html);
console.log(COLOR_GREEN, Success ,fname,new Date(),COLOR_NORMAL)
} else if(/.coffee$/.test(fname)) {
var js = coffeescript.compile(source);
var jsfname = fname.replace(/.coffee$/, .js );
fs.writeFileSync(jsfname, js);
console.log(COLOR_GREEN, Success ,fname,new Date(),COLOR_NORMAL)
} else if(/.less$/.test(fname)) {
var lessparser = new(less.Parser);
var cssfname = fname.replace(/.less$/, .css );
lessparser.parse(source, function (e, tree) {
if(e) {
console.log(COLOR_RED, Failed ,fname,String(e),COLOR_NORMAL);
} else {
fs.writeFileSync(cssfname, tree.toCSS());
console.log(COLOR_GREEN, Success ,fname,new Date(),COLOR_NORMAL)
}
});
}
} catch(e) {
console.log(COLOR_RED, Failed ,fname,String(e),COLOR_NORMAL)
}
}
var walk = function(dir, done) {
var results = [];
fs.readdir(dir, function(err, list) {
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
list.forEach(function(file) {
file = dir + / + file;
fs.stat(file, function(err, stat) {
if (stat && stat.isDirectory()) {
walk(file, function(err, res) {
results = results.concat(res);
if (!--pending) done(null, results);
});
} else {
results.push(file);
if (!--pending) done(null, results);
}
});
});
});
};
function main() {
if(process.argv.length > 2) {
dirName = process.argv[2];
} else {
dirName = . ;
}
stats = fs.statSync(dirName);
if(stats.isDirectory()) {
walk(dirName,function (err, files) {
var watching = 0;
files.forEach(function (fname) {
if(/.coffee$|.less$|.jade$/.test(fname)) {
fs.watchFile(fname,{persistent:true,interval:500},
function (cur,prev) {
if(cur.mtime.getTime() != prev.mtime.getTime()) {
compile(fname);
}
}
);
watching++;
}
});
if(watching) {
console.log( Watching +watching+ file(s) in +
COLOR_YELLOW+dirName+COLOR_NORMAL);
} else {
console.log( No coffee/jade/less files found to watch );
}
});
} else {
// It s a file
var fname = dirName;
if(/.coffee$|.less$|.jade$/.test(fname)) {
fs.watchFile(fname,{persistent:true,interval:500},
function (cur,prev) {
if(cur.mtime.getTime() != prev.mtime.getTime()) {
compile(fname);
}
}
);
console.log( Watching +COLOR_YELLOW+fname+COLOR_NORMAL);
} else {
console.log( No coffee/jade/less files found to watch );
}
}
}
main();
I ve got a ruby web app that uses lilypond to generate sheet music based on user input. I d like to move the hosting to heroku (I ve recently used heroku on a few projects and really liked it, plus ...
ActiveScaffold apparently creates public/blank.html every time the server starts, even if that file already exists (so adding it to version control doesn t help). This is causing my application to ...
(Using Vista)I m trying to clone an app from my GitHub Repository and push it into Heroku. Okay, so I ve tried to create an SSH key so many times with this: `ssh-keygen -t rsa` It seems to go ...
I am trying to clone a git repo that I forked in my GitHub Repository.It s a rails app. I want to clone it on my local git so that I can push it onto heroku. I generated a set of rsa keys and copied ...
Ok, so I have a big github project that i m not supposed to merge my little Stacia branch into. However, it seems like Heroku only takes pushing MASTER seriously. It looks like I pushed my branch, but ...
Has anyone got RadiantCMS with multi_site working on Heroku? I actually tried it and it bombed big-time giving the error: Heroku | No such app There is no app configured at that hostname. Perhaps the ...
I m a rails newbie, I ve been trying to figure out what is going on with the stylesheets_link_tag on heroku. If I use = stylesheet_link_tag "style", :cache => true heroku uses "all.css" and does ...
I ve been migrating some of my MySQL queries to PostgreSQL to use Heroku. Most of my queries work fine, but I keep having a similar recurring error when I use group by: ERROR: column "XYZ" must ...