0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
Commit Graph

40 Commits

Author SHA1 Message Date
XadillaX
f6caeb9526
os: make EOL configurable and read only
PR-URL: https://github.com/nodejs/node/pull/14622
Fixes: https://github.com/nodejs/node/issues/14619
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-08-21 00:23:24 -04:00
Mudit Ameta
4a6b678070
os: add CIDR support
This patch adds support for CIDR notation to the output of the
`networkInterfaces()` method

PR-URL: https://github.com/nodejs/node/pull/14307
Fixes: https://github.com/nodejs/node/issues/14006
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-08-14 15:43:10 -04:00
James M Snell
473572ea25 os: refactor os structure, add Symbol.toPrimitive
Refactor the structure of the os module to use more efficient
module.exports = {} pattern.

Add Symbol.toPrimitive support to os methods that return simple
primitives. This is a minor tweak that makes using these slightly
more friendly when doing things like:

```js
var m = `${os.tmpdir}/foo`
```

PR-URL: https://github.com/nodejs/node/pull/12654
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-05-01 11:44:56 -07:00
James M Snell
98e54b0bd4 meta: restore original copyright header
A prior io.js era commit inappropriately removed the
original copyright statements from the source. This
restores those in any files still remaining from that
edit.

Ref: https://github.com/nodejs/TSC/issues/174
Ref: https://github.com/nodejs/node/pull/10599
PR-URL: https://github.com/nodejs/node/pull/10155

Note: This PR was required, reviewed-by and approved
by the Node.js Foundation Legal Committee and the TSC.
There is no `Approved-By:` meta data.
2017-03-10 11:23:48 -08:00
Brian White
4e05952a8a
os: improve cpus() performance
PR-URL: https://github.com/nodejs/node/pull/11564
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
2017-03-02 15:31:21 -05:00
Brian White
efdc571a58
os: improve loadavg() performance
PR-URL: https://github.com/nodejs/node/pull/11516
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-02-25 20:53:56 -05:00
James M Snell
5de3cf099c lib: add static identifier codes for all deprecations
Assigns a static identifier code to all runtime and documentation
only deprecations. The identifier code is included in the emitted
DeprecationWarning.

Also adds a deprecations.md to the API docs to provide a central
location where deprecation codes can be referenced and explained.

PR-URL: https://github.com/nodejs/node/pull/10116
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Michal Zasso <targos@protonmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2017-01-30 11:11:57 -08:00
Rich Trott
a68987c154 benchmark,lib,test: adjust for linting
Formatting changes for upcoming linter update.

PR-URL: https://github.com/nodejs/node/pull/10561
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2017-01-06 14:36:01 -08:00
Jeremiah Senkpiel
5e5ec2cd1e os: deprecate tmpDir() in favour of tmpdir()
`tmpdir()` was introduced as replacement 3 years ago in
3fe6aba558

PR-URL: https://github.com/nodejs/node/pull/6739
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-06-30 14:52:13 +02:00
James M Snell
dcccbfdc79 src: refactor require('constants')
The require('constants') module is currently undocumented and mashes
together unrelated constants. This refactors the require('constants')
in favor of distinct os.constants, fs.constants, and crypto.constants
that are specific to the modules for which they are relevant. The
next step is to document those within the specific modules.

PR-URL: https://github.com/nodejs/node/pull/6534
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
2016-05-17 11:05:18 -07:00
cjihrig
d6e56fd843 os: add userInfo() method
os.userInfo() calls libuv's uv_os_get_passwd() function. It returns
an object containing the current effective user's username, uid,
gid, shell, and home directory. On Windows, the uid and gid are
-1, and the shell is null.

Refs: https://github.com/nodejs/node/issues/5582
PR-URL: https://github.com/nodejs/node/pull/6104
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-12 17:21:29 -04:00
Jackson Tian
91466b855f lib: refactor code with startsWith/endsWith
reduce using RegExp for string test. This pull reuqest replaces
various usages of regular expressions in favor of the ES2015
startsWith and endsWith methods.

PR-URL: https://github.com/nodejs/node/pull/5753
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-03-23 15:58:52 +02:00
Rich Trott
fdeb862f2b lib: remove unused modules
Some files in `lib` were using `require` to load modules that were
subsequently not used in the file. This removes those `require`
statements.

PR-URL: https://github.com/nodejs/node/pull/4396
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-12-25 13:05:23 -08:00
Sakthipriyan Vairamani
9cd44bb2b6 util: prepend '(node) ' to deprecation messages
Changes included in this commit are

   1. Making the deprecation messages consistent. The messages will be in
      the following format

           x is deprecated. Use y instead.

      If there is no alternative for `x`, then the ` Use y instead.` part
      will not be there in the message.

   2. All the internal deprecation messages are printed with the prefix
      `(node) `, except when the `--trace-deprecation` flag is set.

Fixes: https://github.com/nodejs/io.js/issues/1883
PR-URL: https://github.com/nodejs/io.js/pull/1892
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-07-03 16:32:29 +02:00
cjihrig
6e78e5feaa os: add homedir()
os.homedir() calls libuv's uv_os_homedir() to retrieve the current
user's home directory.

PR-URL: https://github.com/nodejs/io.js/pull/1791
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-06-05 22:58:14 -04:00
cjihrig
76937051f8 os: refine tmpdir() trailing slash stripping
os.tmpdir() began stripping trailing slashes in
b57cc51d8d. This causes problems if
the temp directory is simply '/'. It also stripped trailing
slashes without first determining which slash type is used by
the current operating system. This commit only strips trailing
slashes if another character precedes the slash. On Windows, it
checks for ':', as not to strip slashes from something like 'C:\'.
It also only strips slashes that are appropriate for the user's
operating system.

Fixes: https://github.com/iojs/io.js/issues/1669
PR-URL: https://github.com/iojs/io.js/pull/1673
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Christian Tellnes <christian@tellnes.no>
2015-05-13 10:16:44 -04:00
Christian Tellnes
b57cc51d8d os: remove trailing slash from os.tmpdir()
This commit makes `os.tmpdir()` behave consistently on all platforms. It
changes `os.tmpdir()` to always return a path without trailing slash.

Semver: major
Fixes: https://github.com/iojs/io.js/issues/715
PR-URL: https://github.com/iojs/io.js/pull/747
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-28 14:38:14 -07:00
cjihrig
804e7aa9ab lib: use const to define constants
This commit replaces a number of var statements throughout
the lib code with const statements.

PR-URL: https://github.com/iojs/io.js/pull/541
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 16:21:31 -05:00
isaacs
3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Ben Noordhuis
21130c7d6f lib: turn on strict mode
Turn on strict mode for the files in the lib/ directory.  It helps
catch bugs and can have a positive effect on performance.

PR-URL: https://github.com/node-forward/node/pull/64
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-22 17:23:30 +01:00
Ben Noordhuis
355b96b605 lib,src: make os.endianness() inlinable
Turn os.endianness() from a run-time function into a pure JS function.
Upsides: makes it a good candidate for inlining at the call site.
Downsides: none that I can think of.

PR-URL: https://github.com/node-forward/node/pull/55
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-11 12:02:27 +01:00
isaacs
9100dd4b0f lint
Fixes lint errors introduced in 120e5a24df
2013-03-28 13:19:08 -07:00
Suwon Chae
120e5a24df os: use %SystemRoot% or %windir% in os.tmpdir()
On Windows, respect the SystemRoot and windir environment variables,
don't default to c:\windows\temp.
2013-03-28 16:44:51 +01:00
Ben Noordhuis
3fe6aba558 os: rename tmpDir() to tmpdir() for consistency
Make the casing consistent with the other os.* functions but keep
os.tmpDir() around as an alias.
2013-01-30 04:24:58 +01:00
Nathan Rajlich
5e4e87ade5 os: add os.endianness() function 2012-11-08 12:31:45 -08:00
isaacs
5b39929d47 Add --no-deprecation and --trace-deprecation flags 2012-06-21 12:05:33 -07:00
isaacs
a11bf99ce0 Fix #3407 os.tmpDir() 2012-06-12 19:08:47 -07:00
Mustansir Golawala
7ee15457ed os: add cross platform EOL character 2012-04-14 23:17:38 +02:00
isaacs
0cdf85e28d Lint all the JavaScripts. 2012-02-18 15:34:57 -08:00
Brandon Benvie
5403a8ce4c core: add NativeModule.prototype.deprecate
Formalize and cleanup handling of deprecated core methods.
2012-01-30 00:27:07 +01:00
Ben Noordhuis
97900776bb util: add internal function _deprecationWarning() 2011-12-14 13:36:21 +01:00
Ben Noordhuis
37bb37d151 os: rename getNetworkInterfaces() to networkInterfaces() 2011-11-01 18:10:06 +01:00
isaacs
a7ce79124e Add arch/platform to os module 2011-04-26 20:04:32 -07:00
Ryan Dahl
19e53512b8 os.getNetworkInterfaces() 2011-03-16 16:34:12 -07:00
Ryan Dahl
55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
Ryan Dahl
9bcfc0745c Revert "Implement os.isWindows"
This reverts commit 9e31e0837e.

Use process.platform == 'win32'
2011-01-13 20:32:36 -08:00
Ryan Dahl
5a05992155 Lint 2011-01-06 16:06:27 -08:00
Bert Belder
9e31e0837e Implement os.isWindows 2011-01-04 18:38:58 -08:00
Brian White
d75c338dd6 Add more functionality to the os module 2010-12-22 11:01:25 -08:00
Brian White
f1762ff815 Add os module and getHostname 2010-12-11 00:51:20 -08:00