Commit Graph

82 Commits (8c868989be778246bc4b9558f087d0f93724b83d)

Author SHA1 Message Date
Maciej Małecki 4f1ae11a62 module: eliminate double `getenv()`
`process.env` access results in a synchronous `getenv` call. Cache the
first result instead and save one syscall.
2014-07-31 08:59:46 -07:00
Wyatt Preul 1d5e797445 module: only cache package main 2013-12-12 09:38:47 -08:00
isaacs 875e4a0c59 core: Remove the nextTick for running the main file
Not necessary, since we can handle the error properly on the first tick
now, even if there are event listeners, etc.

Additionally, this removes the unnecessary "_needTickCallback" from
startup, since Module.loadMain() will kick off a nextTick callback right
after it runs the main module.

Fix #4856
2013-02-27 16:29:36 -08:00
isaacs 15508589a1 addon: Pass module object to NODE_MODULE init function
mainly to allow native addons to export single functions on
rather than being restricted to operating on an existing
object.

Init functions now receive exports as the first argument, like
before, but also the module object as the second argument, if they
support it.

Related to #4634

cc: @rvagg
2013-01-25 14:25:35 -08:00
Felix Böhm 7465cf911a module: assert that require() is called with a string
as requested in #4577
2013-01-16 12:25:06 -08:00
James Campos c93c99c7c3 assert that require() has a truthy path 2013-01-16 10:49:19 -08:00
isaacs 8509073458 lint 2012-10-12 11:46:36 -07:00
Bert Belder 5288ed75be windows: use USERPROFILE to get the user's home dir
Fixes #3461
Close #3462
Close #4093
2012-10-09 00:47:38 +02:00
tasogarepg 21c4b9a9eb debugger: fix --debug-brk 2012-09-18 10:56:37 +04:00
isaacs 22804a9eb8 module: use 'repl' as the filename arg if missing
Fix #3859
2012-08-13 22:07:03 +02:00
TJ Holowaychuk ed7fb149a2 module: add filename to require() json errors
Otherwise it can be quite difficult to figure out which file is busted.

Closes #3580.
2012-07-06 15:26:41 -07:00
isaacs 07be9fc3a6 Merge remote-tracking branch 'ry/v0.6' into v0.6-merge
Conflicts:
	Makefile
	lib/zlib.js
	src/node.cc
	src/node.js
2012-05-09 15:12:13 -07:00
Felix Geisendörfer bf9d8e9214 Fix exception output for module load exceptions
So instead of:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^

You will now see:

path/to/foo.js:1
throw new Error('bar');
      ^

This is a sub-set of isaacs patch here:

https://github.com/joyent/node/issues/3235

The difference is that this patch purely adresses the exception output,
but does not try to make any behavior changes / improvements.
2012-05-09 11:54:43 -07:00
Shigeki Ohtsu 891f9defeb No need to have NativeModule.require('fs') in Module._findPath() 2012-03-19 18:58:58 -07:00
isaacs a10cfba766 module: remove 'exited', replace 'children' array 2012-03-12 10:27:11 -07:00
Ben Noordhuis 8a6576f764 Merge remote-tracking branch 'origin/v0.6'
Conflicts:
	common.gypi
2012-02-12 16:12:26 +01:00
Ben Noordhuis 09c296b44d debugger: fix --debug-brk
Commit 840229a forgot to update the debugger special case in lib/module.js

Fixes #2710.
2012-02-07 23:16:40 +01:00
Ben Noordhuis 3deceaf6e7 Revert "Process symlinked shared library as .node"
This reverts commit 7e0bf7d57d.

It's possible to make GYP generate an XCode project that produces a .node file,
hence this commit is no longer needed.
2012-02-01 22:49:56 +01:00
Ben Noordhuis a9723df1b7 Revert "Process symlinked shared library as .node"
This reverts commit 7e0bf7d57d.

It's possible to make GYP generate an XCode project that produces a .node file,
hence this commit is no longer needed.
2012-02-01 22:28:23 +01:00
isaacs 18d179c2d8 Merge remote-tracking branch 'ry/v0.6' into master
Conflicts:
	ChangeLog
	deps/uv/src/unix/udp.c
	deps/uv/src/win/fs.c
	deps/uv/src/win/udp.c
	deps/uv/test/test-fs.c
	doc/index.html
	doc/logos/index.html
	doc/template.html
	src/node_version.h
2012-01-31 18:18:00 -08:00
Paddy Byers 7e0bf7d57d Process symlinked shared library as .node 2012-01-31 17:50:16 -08:00
Paddy Byers 840229a825 Tidy _resolveFilename 2012-01-31 17:50:11 -08:00
Fedor Indutny ccf7b41a69 module: fix --debug-brk on symlinked scripts
* fixes #1519
2012-01-24 19:07:38 +01:00
Fedor Indutny 27c85727ed module: fix --debug-brk on symlinked scripts
* fixes #1519
2012-01-24 23:13:37 +06:00
Nathan Rajlich 3f987cd925 module: Set the error.code to 'MODULE_NOT_FOUND' when a bad path is given to require.
Fixes #2358.
2011-12-19 23:46:41 +09:00
Ben Leslie a4e10cdb07 Raise an error when a malformed package.json file is found.
The current behaviour will silently ignore any parsing errors
that may occur when loading a package.json file. This makes
debugging errors in the package.json file very difficult.

This changes the behaviour that that errors opening and reading
the file package.json file continue to be ignored, but errors
in parsing will throw an exception.
2011-09-23 12:00:26 -07:00
Ryan Dahl a1bafc5566 Merge remote branch 'origin/v0.4'
Conflicts:
	deps/http_parser/http_parser.c
	deps/http_parser/test.c
	lib/repl.js
2011-09-15 11:48:37 -07:00
isaacs e06ce7562c Fix #1707 hasOwnProperty usage
If hasOwnProperty is overridden, then calling `obj.hasOwnProperty(prop)`
can fail.  Any time a dictionary of user-generated items is built, we
cannot rely on hasOwnProperty being safe, so must call it from the
Object.prototype explicitly.
2011-09-15 10:54:08 -07:00
isaacs 98990b9779 Fix #1707 hasOwnProperty usage 2011-09-15 09:46:30 -07:00
Ben Noordhuis ac722bbed6 module: strip byte order marker when loading *.js and *.json files
BOMs make V8 raise a 'SyntaxError: Unexpected token ILLEGAL' exception.

Fixes #1440.
2011-08-04 16:52:55 +02:00
isaacs 703a1ffe52 Revert "AMD compatibility for node"
This reverts commit 9967c369c9.

Conflicts:

	test/simple/test-module-loading.js
2011-07-29 11:56:38 -07:00
isaacs 588d885e81 Close #1357 Load json files with require()
Signed off by everybody.
2011-07-20 17:39:23 -07:00
isaacs 448eab2587 Close #1349 Delimit NODE_PATH with ; on Windows 2011-07-17 14:35:49 -07:00
isaacs 7f0047c2d5 Close #1348 Remove require.paths
Module.globalPaths is still set to a read-only copy of the global
include paths pulled off of the NODE_PATH environment variable.

It's important to be able to inspect this, but modifying it no longer
has any effect.
2011-07-15 15:11:33 -07:00
isaacs 9b5098f509 Close #1281 Make require a public member of module
Reviewed by @felixge
2011-07-14 14:25:49 -07:00
Ryan Dahl 23b8931b62 Merge branch 'v0.4'
Conflicts:
	src/node.js
	src/node_version.h
2011-06-29 14:50:03 +02:00
Ryan Dahl 52b517c6ab Revert "Add --cov code coverage option"
This can be done in user space. EG https://github.com/cloudkick/whiskey

This reverts commit da9b3340eb.
This reverts commit b4ff36a41b.

Conflicts:

	src/node.cc
2011-06-17 14:03:05 +02:00
Mathias Buus 39246f65df Closes #1177 remove one node_modules optimization
to better support certain project structures.
2011-06-14 15:32:41 -07:00
isaacs 9967c369c9 AMD compatibility for node, with docs and tests
Closes #1173
Closes #1170
2011-06-13 16:11:13 -07:00
Ryan Dahl b4ff36a41b Add --cov code coverage option 2011-04-14 23:42:08 -07:00
Ryan Dahl 75db1995b6 Don't conflict with V8's Script class
Closes GH-203.
2011-03-30 10:06:25 -07:00
Ryan Dahl 55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
isaacs 3599c71dae Closes GH-690 node_modules folders should be highest priority 2011-02-27 17:14:16 -08:00
Felix Geisendörfer 66601f13d9 Do not cache modules that throw exceptions
If a module throws an exception on load, it should not be cached.
This patch shows the problem in a test case and also fixes it.

See: https://groups.google.com/forum/#!topic/nodejs-dev/1cIrvJcADbY

Closes GH-707
Closes GH-710
2011-02-24 16:14:04 -08:00
isaacs f8defa3e09 package.json main as indexed subdir
Closes GH-686.
2011-02-18 10:43:06 -08:00
isaacs 46513483cd node_modules module lookup, +docs and test. 2011-02-09 14:24:22 -08:00
isaacs 9bed5dcb2c Support caching for realpath, use in module load
This adds support for a cache object to be passed to the
fs.realpath and fs.realpathSync functions.  The Module loader keeps an
object around which caches the resulting realpaths that it looks up in
the process of loading modules.

This means that (at least as a result of loading modules) the same files
and folders are never lstat()ed more than once.  To reset the cache, set
require("module")._realpathCache to an empty object.  To disable the
caching behavior, set it to null.
2011-02-08 18:02:59 -08:00
isaacs da2f4b2dc4 support for package.json
This adds basic support for situations where there is a package.json
with a "main" field.  That "main" module is used as the code that is
loaded when the package folder is required.
2011-02-07 11:00:22 -08:00
isaacs 2f1f22ab26 module: define functions only once. 2011-02-03 14:23:28 -08:00
isaacs f86ec1366f Closes GH-619 Make require.main be the main module 2011-02-02 11:18:34 -08:00