Permalink
Browse files

Package tweaks

Detect on load when the fibers library is older than node, which
probably means your build is out date. Also fix it so that `npm rebuild
fibers` works.
  • Loading branch information...
1 parent f8631b2 commit 20531ad39a8ea4a33fa21a6ae9a7a87550271d23 @laverdet committed Jan 24, 2011
Showing with 14 additions and 12 deletions.
  1. +11 −9 fibers.js
  2. +3 −3 package.json
View
@@ -1,13 +1,13 @@
-if (process.env.FIBER_SHIM) {
- require('./src/fibers');
- return;
-}
+var fs = require('fs');
-/**
- * If the library wasn't preloaded then we should gracefully fail instead of segfaulting if they
- * attempt to use a Fiber.
- */
-Fiber = function() {
+if (fs.statSync(process.execPath).mtime >
+ fs.statSync(require.resolve('./src/fibers')).mtime) {
+ throw new Error(
+ '`node` has a newer mtime than `fiber`; it is possible your build is out of date. This ' +
+ 'could happen if you upgrade node. Try `npm rebuild fibers` to rebuild. If that doesn\'t ' +
+ 'work you could consider running `touch ' + require.resolve('./src/fibers') + '` and maybe ' +
+ 'there won\'t be a problem.');
+} else if (!process.env.FIBER_SHIM) {
throw new Error(
'Fiber support was not enabled when you ran node. To enable support for fibers, please run ' +
'node with the included `node-fibers` script. For example, instead of running:\n\n' +
@@ -16,3 +16,5 @@ Fiber = function() {
' node-fibers script.js\n\n' +
'You will not be able to use Fiber without this support enabled.');
}
+
+require('./src/fibers');
View
@@ -1,13 +1,13 @@
{
"name": "fibers",
- "version": "0.1.0",
- "description": "Cooperative multi-tasking for Javascript; or, the closet thing to a thread you'll see in node",
+ "version": "0.1.1",
+ "description": "Cooperative multi-tasking for Javascript; or, the closest thing to a thread you'll see in node",
"keywords": ["fiber", "fibers", "coroutine", "thread", "async", "parallel", "worker"],
"homepage": "https://github.com/laverdet/node-fibers",
"author": "Marcel Laverdet <marcel@laverdet.com> (https://github.com/laverdet/)",
"main": "fibers",
"scripts": {
- "install": "make"
+ "install": "make clean all"
},
"bin": {
"node-fibers": "./bin/node-fibers",

0 comments on commit 20531ad

Please sign in to comment.