Skip to content
Browse files

failed attempts for working with npm to over write the build and run-…

…script

sent email to mailing list, waiting for any results
  • Loading branch information...
1 parent ae3cd42 commit a2604aa90cde341b569ba844b2df7cddafacc3c9 @matthewfl committed Jul 3, 2011
Showing with 67 additions and 3 deletions.
  1. +3 −1 config.sample.js
  2. +1 −1 lib/npm
  3. +63 −1 npm_fetch.js
View
4 config.sample.js
@@ -25,4 +25,6 @@ exports.dbPort='/tmp/tyrant';
exports.dbHost="";
exports.dbSyncTime=10*1000;
-exports.deleteDomainFile="/home/matthew/jsapp_delete_domain"; // change this to some place that you can write to
+exports.deleteDomainFile="/home/matthew/jsapp_delete_domain"; // change this to some place that you can write to
+
+exports.npm_working_folder="/home/matthew/npm_working_folder"; // make this some temp folder or place where it can do the work of installing files
2 lib/npm
@@ -1 +1 @@
-Subproject commit 732d4d0394fcb6e15d388937acae7b2512729b3f
+Subproject commit eedf0c938f11450634dca38f59578347508ee296
View
64 npm_fetch.js
@@ -1,7 +1,69 @@
var db = require('./db');
var config = require('./config');
var async = require('./lib/async').async;
+var fs = require('fs');
var npm = require('./lib/npm/npm.js');
-console.log(npm);
+try {
+ fs.lstatSync(config.npm_working_folder)
+} catch (e) {
+ fs.mkdirSync(config.npm_working_folder, 460);
+ fs.mkdirSync(config.npm_working_folder + "/bin", 460);
+ fs.mkdirSync(config.npm_working_folder + "/man", 460);
+ fs.mkdirSync(config.npm_working_folder + "/root", 460);
+ fs.mkdirSync(config.npm_working_folder + "/cache", 460);
+ fs.mkdirSync(config.npm_working_folder + "/prefix", 460);
+}
+
+npm.load({
+ binroot: config.npm_working_folder + "/bin",
+ manroot: config.npm_working_folder + "/man",
+ root: config.npm_working_folder + "/root",
+ cache: config.npm_working_folder + "/cache",
+ globalconfig: config.npm_working_folder + "/global_config_file",
+ prefix: config.npm_working_folder + "/prefix",
+ userconfig: config.npm_working_folder + "/user_config_file",
+ userignorefile: config.npm_working_folder + "/user_ignore_file"
+}, function (err) {
+ //npm.commands.build = console.log;
+ //npm.commands['run-script'] = console.log;
+ //Object.defineProperty(npm.commands, "build", { get: function () { return console.log; }});
+ //Object.defineProperty(npm.commands, "run-script", { value: console.log });
+ var original_npm = npm.commands;
+ npm.commands = {}; // more hacks, to make npm safe
+ for(var c in original_npm) {
+ (function (c) {
+ Object.defineProperty(npm.commands, c, { get : function () {
+ console.log("=======================================================================loading command", c);
+ if(c == "build" || c == "run-script")
+ return console.log;
+ return function () {
+ console.log.apply(this, arguments);
+ original_npm[c].apply(this, arguments);
+ };
+ }});
+ })(c);
+ }
+
+ npm.commands.install(['7digital-api'], console.log)
+/*
+ console.log("loaded npm");
+ npm.commands.search([], function (err, list) {
+ console.log("retreved list");
+ var c=10;
+ for(var a in list) {
+ npm.commands.info([a], function (err, info) {
+ for(var names in info) { // why must I use this hack
+ info = info[names][''];
+ break;
+ }
+ if(typeof info.versions == "string") info.versions = [ info.versions ];
+ console.log(info.name, info.versions);
+ npm.commands.install([info.name], console.log);
+ });
+ if(!c--) return;
+ }
+ });
+ */
+});

0 comments on commit a2604aa

Please sign in to comment.
Something went wrong with that request. Please try again.