Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/node-gyp/lib/util/hook.js')
-rw-r--r--node_modules/node-gyp/lib/util/hook.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/node_modules/node-gyp/lib/util/hook.js b/node_modules/node-gyp/lib/util/hook.js
deleted file mode 100644
index d31cc2e8a..000000000
--- a/node_modules/node-gyp/lib/util/hook.js
+++ /dev/null
@@ -1,48 +0,0 @@
-
-/**
- * This is our "Hook" class that allows a script to hook into the lifecyle of the
- * "configure", "build" and "clean" commands. It's basically a hack into the
- * module.js file to allow custom hooks into the module-space, specifically to
- * make the global scope act as an EventEmitter.
- */
-
-var fs = require('fs')
- , path = require('path')
- , Module = require('module')
- , EventEmitter = require('events').EventEmitter
- , functions = Object.keys(EventEmitter.prototype).filter(function (k) {
- return typeof EventEmitter.prototype[k] == 'function'
- })
- , boilerplate = functions.map(function (k) {
- return 'var ' + k + ' = module.emitter.' + k + '.bind(module.emitter);'
- }).join('')
-
-module.exports = createHook
-function createHook (filename, callback) {
-
- var emitter = new EventEmitter
-
- // first read the file contents
- fs.readFile(filename, 'utf8', function (err, code) {
- if (err) {
- if (err.code == 'ENOENT') {
- // hook file doesn't exist, oh well
- callback(null, emitter)
- } else {
- callback(err)
- }
- return
- }
- // got a hook file, now execute it
- var mod = new Module(filename)
- mod.filename = filename
- mod.paths = Module._nodeModulePaths(filename)
- mod.emitter = emitter
- try {
- mod._compile(boilerplate + code, filename)
- } catch (e) {
- return callback(e)
- }
- callback(null, emitter)
- })
-}