first commit
This commit is contained in:
9
build/node_modules/os-shim/.editorconfig
generated
vendored
Normal file
9
build/node_modules/os-shim/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
5
build/node_modules/os-shim/.npmignore
generated
vendored
Normal file
5
build/node_modules/os-shim/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/node_modules/
|
||||
npm-debug.log
|
||||
.DS_Store
|
||||
.idea/
|
||||
Thumbs.db
|
||||
8
build/node_modules/os-shim/.travis.yml
generated
vendored
Normal file
8
build/node_modules/os-shim/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10.0"
|
||||
- "0.8.0"
|
||||
- "0.6.0"
|
||||
- "0.4.0"
|
||||
|
||||
script: make test
|
||||
23
build/node_modules/os-shim/LICENSE
generated
vendored
Normal file
23
build/node_modules/os-shim/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright 2013 Adesis Netlife S.L and constributors
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
9
build/node_modules/os-shim/Makefile
generated
vendored
Normal file
9
build/node_modules/os-shim/Makefile
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
-u tdd \
|
||||
--ui exports \
|
||||
--reporter spec \
|
||||
--slow 1000ms \
|
||||
--bail
|
||||
|
||||
.PHONY: test
|
||||
98
build/node_modules/os-shim/README.md
generated
vendored
Normal file
98
build/node_modules/os-shim/README.md
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
# Node OS shim [][travis] [][badge]
|
||||
|
||||
> Native OS module API shim for older node.js versions
|
||||
|
||||
## About
|
||||
|
||||
Node.js team froze the [OS module API][1] in 0.10.x version, however the API differs a bit in lower node.js versions
|
||||
|
||||
This shim just provides the missing OS module API that is available on latest node.js versions.
|
||||
You can now use the `os` package in old node.js versions without fear.
|
||||
|
||||
It's based on the current node.js [implementations][2]
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm install os-shim --save[-dev]
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You simply should use the `os-shim` module instead of the `os` native node.js module
|
||||
|
||||
```js
|
||||
var os = require('os-shim')
|
||||
os.tmpdir()
|
||||
```
|
||||
You can mutate the `os-shim` module object without worring about it can create side effects in the native `os` module object
|
||||
|
||||
## The missing API
|
||||
|
||||
The following API is missing in node.js `0.8.x` and lower versions
|
||||
|
||||
#### os.tmpdir()
|
||||
Returns the operating system's default directory for temp files
|
||||
|
||||
#### os.endianness()
|
||||
Returns the endianness of the CPU. Possible values are "BE" or "LE"
|
||||
|
||||
#### os.EOL
|
||||
A constant defining the appropriate End-of-line marker for the operating system
|
||||
|
||||
#### os.platform()
|
||||
Returns the operating system platform
|
||||
|
||||
#### os.arch()
|
||||
Returns the operating system CPU architecture
|
||||
|
||||
## Contributing
|
||||
|
||||
Instead of a formal styleguide, take care to maintain the existing coding style.
|
||||
|
||||
Add unit tests for any new or changed functionality
|
||||
|
||||
### Development
|
||||
|
||||
Clone the repository
|
||||
```shell
|
||||
$ git clone https://github.com/adesisnetlife/node-os-shim.git && cd node-os-shim
|
||||
```
|
||||
|
||||
Install dependencies
|
||||
```shell
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Run tests
|
||||
```shell
|
||||
$ make test
|
||||
```
|
||||
|
||||
## Release History
|
||||
|
||||
- **0.1.1** `2013-12-11`
|
||||
- Add platform() and arch() methods (for Node.js 0.4.x)
|
||||
- **0.1.0** `2013-12-11`
|
||||
- Initial release
|
||||
|
||||
## To Do
|
||||
|
||||
- Add `os.networkInterfaces()` shim method
|
||||
|
||||
Do you miss something? Open an issue or make a PR!
|
||||
|
||||
## Contributors
|
||||
|
||||
* [Tomas Aparicio](http://github.com/h2non)
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2013 Adesis Netlife S.L and contributors
|
||||
|
||||
Released under MIT license
|
||||
|
||||
[1]: http://nodejs.org/api/os.html
|
||||
[2]: https://github.com/joyent/node/blob/master/lib/os.js
|
||||
[travis]: http://travis-ci.org/AdesisNetlife/node-os-shim
|
||||
[badge]: http://badge.fury.io/js/os-shim
|
||||
74
build/node_modules/os-shim/lib/os.js
generated
vendored
Normal file
74
build/node_modules/os-shim/lib/os.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
var os = require('os')
|
||||
var osShim
|
||||
|
||||
'use strict';
|
||||
|
||||
// clone the 'os' module object to avoid mutations and unexpected behavior
|
||||
module.exports = osShim = clone(os)
|
||||
|
||||
//
|
||||
// apply the missing API
|
||||
//
|
||||
|
||||
if (!os.tmpdir) {
|
||||
osShim.tmpdir = tmpdir
|
||||
}
|
||||
|
||||
if (!os.platform) {
|
||||
osShim.platform = platform
|
||||
}
|
||||
|
||||
if (!os.arch) {
|
||||
osShim.arch = arch
|
||||
}
|
||||
|
||||
if (!os.endianness) {
|
||||
osShim.endianness = endianness
|
||||
}
|
||||
|
||||
if (!os.EOL) {
|
||||
Object.defineProperty(osShim, 'EOL', {
|
||||
get: function () {
|
||||
return process.platform === 'win32' ? '\n\r' : '\n'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function tmpdir() {
|
||||
var isWindows = process.platform === 'win32'
|
||||
var env = process.env
|
||||
|
||||
if (isWindows) {
|
||||
return env.TEMP ||
|
||||
env.TMP ||
|
||||
(env.SystemRoot || env.windir) + '\\temp';
|
||||
} else {
|
||||
return env.TMPDIR ||
|
||||
env.TMP ||
|
||||
env.TEMP ||
|
||||
'/tmp';
|
||||
}
|
||||
}
|
||||
|
||||
function platform() {
|
||||
return process.platform
|
||||
}
|
||||
|
||||
function arch() {
|
||||
return process.arch
|
||||
}
|
||||
|
||||
function endianness() {
|
||||
var isEndianness = ((new Uint32Array((new Uint8Array([1,2,3,4])).buffer))[0] === 0x04030201)
|
||||
return isEndianness ? 'LE' : 'BE'
|
||||
}
|
||||
|
||||
function clone(object) {
|
||||
var prop, cloneObj = {}
|
||||
for (prop in object) {
|
||||
if (object.hasOwnProperty(prop)) {
|
||||
cloneObj[prop] = object[prop]
|
||||
}
|
||||
}
|
||||
return cloneObj
|
||||
}
|
||||
65
build/node_modules/os-shim/package.json
generated
vendored
Normal file
65
build/node_modules/os-shim/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"_from": "os-shim@^0.1.2",
|
||||
"_id": "os-shim@0.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=",
|
||||
"_location": "/os-shim",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "os-shim@^0.1.2",
|
||||
"name": "os-shim",
|
||||
"escapedName": "os-shim",
|
||||
"rawSpec": "^0.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/spawn-sync"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz",
|
||||
"_shasum": "6b62c3791cf7909ea35ed46e17658bb417cb3917",
|
||||
"_spec": "os-shim@^0.1.2",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/spawn-sync",
|
||||
"bugs": {
|
||||
"url": "https://github.com/h2non/node-os-shim/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Tomas Aparicio",
|
||||
"email": "tomas@aparicio.me"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "Native OS module API shim for older node.js versions",
|
||||
"devDependencies": {
|
||||
"expect.js": "~0.2.0",
|
||||
"mocha": "~1.15.1"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"homepage": "http://github.com/h2non/node-os-shim",
|
||||
"keywords": [
|
||||
"os",
|
||||
"tmpdir",
|
||||
"endianness",
|
||||
"shim"
|
||||
],
|
||||
"licenses": "MIT",
|
||||
"main": "lib/os",
|
||||
"name": "os-shim",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/h2non/node-os-shim.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "0.1.3"
|
||||
}
|
||||
142
build/node_modules/os-shim/test/osSpec.js
generated
vendored
Normal file
142
build/node_modules/os-shim/test/osSpec.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
var expect = require('expect.js')
|
||||
var os = require('os')
|
||||
var osCopy = {}
|
||||
var osShim
|
||||
|
||||
var isWin = process.platform === 'win32'
|
||||
var tmpVar = isWin ? 'TEMP' : 'TMPDIR'
|
||||
var tmpDir = process.env[tmpVar]
|
||||
var isNode10 = (/0\.10\./).test(process.versions.node)
|
||||
|
||||
var shimAPI = [ 'tmpdir', 'endianness', 'platform', 'arch', 'EOL' ]
|
||||
|
||||
describe('os', function () {
|
||||
|
||||
before(function () {
|
||||
if (isNode10) {
|
||||
shimAPI.forEach(function (prop) {
|
||||
osCopy[prop] = os[prop]
|
||||
os[prop] = undefined
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
before(function () {
|
||||
osShim = require('../lib/os')
|
||||
})
|
||||
|
||||
after(function () {
|
||||
if (isNode10) {
|
||||
// restore members references
|
||||
shimAPI.forEach(function (prop) {
|
||||
os[prop] = osCopy[prop]
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('should be an object', function () {
|
||||
expect(osShim).to.be.an('object')
|
||||
})
|
||||
|
||||
it('should be a clone object', function () {
|
||||
expect(osShim).to.not.equal(os)
|
||||
})
|
||||
|
||||
describe('API', function () {
|
||||
|
||||
describe('tmpdir()', function () {
|
||||
|
||||
before(function () {
|
||||
process.env[tmpVar] = '/custom/tmp'
|
||||
})
|
||||
|
||||
after(function () {
|
||||
process.env[tmpVar] = tmpDir
|
||||
})
|
||||
|
||||
it('should be expose the method', function () {
|
||||
expect(osShim.tmpdir).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should use the exposed shim method', function () {
|
||||
expect(osShim.tmpdir).to.not.be.equal(os.tmpdir)
|
||||
})
|
||||
|
||||
it('should have the proper temporary directory path', function () {
|
||||
expect(osShim.tmpdir()).to.be.equal('/custom/tmp')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('endianness()', function () {
|
||||
|
||||
it('should be expose the method', function () {
|
||||
expect(osShim.endianness).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should use the exposed shim method', function () {
|
||||
expect(osShim.endianness).to.not.be.equal(os.endianness)
|
||||
})
|
||||
|
||||
it('should return the proper endian value', function () {
|
||||
expect(osShim.endianness()).to.be.an('string')
|
||||
expect(osShim.endianness()).to.match(/LE|BE/)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('EOL', function () {
|
||||
|
||||
it('should be expose the method', function () {
|
||||
expect(osShim.EOL).to.be.a('string')
|
||||
})
|
||||
|
||||
it('should use the exposed shim method', function () {
|
||||
expect(osShim.EOL).to.not.be.equal(os.EOL)
|
||||
})
|
||||
|
||||
it('should return the proper EOL value', function () {
|
||||
if (isWin) {
|
||||
expect(osShim.EOL).to.be.equal('\n\r')
|
||||
} else {
|
||||
expect(osShim.EOL).to.be.equal('\n')
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('platform()', function () {
|
||||
|
||||
it('should be expose the method', function () {
|
||||
expect(osShim.platform).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should use the exposed shim method', function () {
|
||||
expect(osShim.platform).to.not.be.equal(os.platform)
|
||||
})
|
||||
|
||||
it('should return the proper EOL value', function () {
|
||||
expect(osShim.platform()).to.be.equal(process.platform)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('arch()', function () {
|
||||
|
||||
it('should be expose the method', function () {
|
||||
expect(osShim.arch).to.be.a('function')
|
||||
})
|
||||
|
||||
it('should use the exposed shim method', function () {
|
||||
expect(osShim.arch).to.not.be.equal(os.arch)
|
||||
})
|
||||
|
||||
it('should return the proper EOL value', function () {
|
||||
expect(osShim.arch()).to.be.equal(process.arch)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user