Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 22, 2015
0 parents commit 2fa41df
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
12 changes: 12 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"curly": true,
"immed": true,
"newcap": true,
"noarg": true,
"undef": true,
"unused": "vars",
"strict": true
}
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
var childProcess = require('child_process');
var ctor;

module.exports = function () {
if (typeof childProcess.ChildProcess === 'function') {
return childProcess.ChildProcess;
}

if (ctor !== undefined) {
return ctor;
}

var cp = childProcess.spawn(process.execPath);
cp.kill('SIGKILL');
ctor = cp.constructor;

return ctor;
};
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)

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.
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "child-process-ctor",
"version": "0.0.0",
"description": "Node.js childProcess.ChildProcess ponyfill",
"license": "MIT",
"repository": "sindresorhus/child-process-ctor",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js"
},
"files": [
"index.js"
],
"keywords": [
"built-in",
"core",
"ponyfill",
"polyfill",
"shim",
"child",
"process",
"childprocess",
"constructor",
"ctor"
],
"devDependencies": {
"ava": "0.0.4"
}
}
29 changes: 29 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# child-process-ctor [![Build Status](https://travis-ci.org/sindresorhus/child-process-ctor.svg?branch=master)](https://travis-ci.org/sindresorhus/child-process-ctor)

> Node.js `childProcess.ChildProcess` ponyfill
> Ponyfill: A polyfill that doesn't overwrite the native method
The `ChildProcess` constructor weren't previously easily exposed. This is most likely going to [change soon](https://github.com/nodejs/io.js/pull/1760).


## Install

```
$ npm install --save child-process-ctor
```


## Usage

```js
var childProcessCtor = require('child-process-ctor');

console.log(typeof childProcessCtor().prototype.spawn);
//=> 'function'
```


## License

MIT © [Sindre Sorhus](http://sindresorhus.com)
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';
var test = require('ava');
var childProcessCtor = require('./');

test(function (t) {
var ctor = childProcessCtor();
t.assert(ctor.name === 'ChildProcess');
t.assert(typeof ctor.prototype.spawn === 'function');
t.end();
});

0 comments on commit 2fa41df

Please sign in to comment.