From 0f01343d4b8a15b8086451ae41eb0a8d447910f3 Mon Sep 17 00:00:00 2001 From: flames of love Date: Sun, 3 Mar 2013 12:41:31 +0100 Subject: [PATCH] future funkiness! --- README.md | 6 +++++- client_tests.js | 7 +++++++ package.js | 31 ++++++++++++++++++------------- 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 client_tests.js diff --git a/README.md b/README.md index e9a057d..b2c3a15 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,8 @@ I am working on a Npm dependency module for meteor... not ready yet though... due to a bug with multiple components depending on the same component (component-emitter for example), with the stock version of component, you might get hangs... -I have [made a pull request](https://github.com/component/component/pull/276), so you will have to wait, or you can optionally check out my [repo here](https://github.com/heavyk/component) \ No newline at end of file +I have [made a pull request](https://github.com/component/component/pull/276), so you will have to wait, or you can optionally check out my [repo here](https://github.com/heavyk/component) + +# Future + + * add a lock file. when more than one instance of meteor is spawned... things get pretty crazy... diff --git a/client_tests.js b/client_tests.js new file mode 100644 index 0000000..bcdf337 --- /dev/null +++ b/client_tests.js @@ -0,0 +1,7 @@ + + +Tinytest.add("component - presence", function(test) { + test.isTrue(typeof component === 'object'); + test.isTrue(typeof component.require === 'function'); +}); + diff --git a/package.js b/package.js index d68dc9c..97e0c45 100644 --- a/package.js +++ b/package.js @@ -35,8 +35,9 @@ Package.register_extension( var conf = require(source_path); var pkgs = conf.dependencies; if(!pkgs) return; + var st, this_st = fs.statSync(source_path); Fiber(function() { - var st, this_st = fs.statSync(source_path); + var future = new Future; ///* try { st = fs.statSync(component_json_path); @@ -101,26 +102,29 @@ Package.register_extension( batch = new Batch _.each(pkgs, function(url, pkg) { + + var parts = pkg.split('@'); + var name = parts.shift(); + var version = parts.shift() || 'master'; + var rname = pkg.replace('/', '-'); + //TODO: if some time has passed, say 2-3 days, do an update instead of skipping it (for master) + //TODO: when implementing specific versions, do a version compare here and update if necessary + if(fs.existsSync(Path.join(odir, name))) return; batch.push(function(done) { - var parts = pkg.split('@'); - var name = parts.shift(); - var version = parts.shift() || 'master'; - var rname = pkg.replace('/', '-'); - //TODO: if some time has passed, say 2-3 days, do an update instead of skipping it (for master) - //TODO: when implementing specific versions, do a version compare here and update if necessary - if(fs.existsSync(Path.join(odir, name))) return; install(name, version, done); }); }); - var future = new Future; + batch.end(function() {future.return()}); - future.wait() + future.wait(); + future = void(8); try { fs.utimesSync(js_path, new Date, new Date); } catch(e) {} } + //}).run(); //*/ - + //Fiber(function() { try { st = fs.statSync(js_path); } catch(e) {} @@ -132,11 +136,11 @@ Package.register_extension( builder.copyFiles(); builder.addLookup(Path.join(process.cwd(), ".meteor", "components")); console.log(); - future = new Future; + if(!future) future = new Future; builder.build(function(err, obj){ if (err) { Component.utils.fatal(err.message); - future.return(err); + return future.return(err); } fs.writeFileSync(css_path, obj.css); @@ -200,4 +204,5 @@ Package.register_extension( Package.on_test(function (api) { api.add_files(['component_tests.js'], 'server'); + api.add_files(['client_tests.js'], 'client'); });