Skip to content

Commit

Permalink
Update run npm to not use fs directly anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
janjongboom committed May 30, 2012
1 parent 06ba3c8 commit b4cc45e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion plugins-server/cloud9.ide.run-npm-module/package.json
Expand Up @@ -11,7 +11,8 @@
"process-manager",
"run-node",
"ide.ext.state",
"eventbus"
"eventbus",
"sandbox.fs"
]
}
}
10 changes: 6 additions & 4 deletions plugins-server/cloud9.ide.run-npm-module/run-npm-module.js
Expand Up @@ -7,15 +7,17 @@

var Plugin = require("../cloud9.core/plugin");
var util = require("util");
var fs = require("fs");

var name = "npm-runtime";
var ProcessManager;
var EventBus;
var Fs;

module.exports = function setup(options, imports, register) {
ProcessManager = imports["process-manager"];
EventBus = imports.eventbus;
Fs = imports["sandbox.fs"];

imports.ide.register(name, NpmRuntimePlugin, register);
};

Expand Down Expand Up @@ -101,14 +103,14 @@ util.inherits(NpmRuntimePlugin, Plugin);
};

this.searchForModuleHook = function(command, cb) {
var baseDir = this.ide.workspaceDir + "/node_modules";
var baseDir = "node_modules";

function searchModules(dirs, it) {
if (!dirs[it])
return cb(false);

var currentDir = baseDir + "/" + dirs[it];
fs.readFile(currentDir + "/package.json", "utf-8", function(err, file) {
Fs.readFile(currentDir + "/package.json", "utf-8", function(err, file) {
if (err)
return searchModules(dirs, it+1);

Expand All @@ -131,7 +133,7 @@ util.inherits(NpmRuntimePlugin, Plugin);
});
}

fs.readdir(baseDir, function(err, res) {
Fs.readdir(baseDir, function(err, res) {
if (err)
return cb(false);

Expand Down

0 comments on commit b4cc45e

Please sign in to comment.