[Pkg-javascript-commits] [node-exit-hook] 01/03: Import Upstream version 1.1.1

Paolo Greppi paolog-guest at moszumanska.debian.org
Mon Dec 19 11:44:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

paolog-guest pushed a commit to branch master
in repository node-exit-hook.

commit 6283d57ea1a0dfe0346fc5bdb8e1f68bc0e14c9c
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date:   Fri Dec 16 18:07:56 2016 +0000

    Import Upstream version 1.1.1
---
 .editorconfig  | 15 +++++++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .jshintrc      | 13 +++++++++++++
 .travis.yml    |  3 +++
 index.js       | 30 ++++++++++++++++++++++++++++++
 license        | 21 +++++++++++++++++++++
 package.json   | 39 +++++++++++++++++++++++++++++++++++++++
 readme.md      | 40 ++++++++++++++++++++++++++++++++++++++++
 test.js        | 17 +++++++++++++++++
 10 files changed, 180 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..86c8f59
--- /dev/null
+++ b/.editorconfig
@@ -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]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..804f8af
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,13 @@
+{
+	"node": true,
+	"esnext": true,
+	"bitwise": true,
+	"camelcase": true,
+	"curly": true,
+	"immed": true,
+	"newcap": true,
+	"noarg": true,
+	"undef": true,
+	"unused": "vars",
+	"strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..244b7e8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+  - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..e18013f
--- /dev/null
+++ b/index.js
@@ -0,0 +1,30 @@
+'use strict';
+
+var cbs = [];
+var called = false;
+
+function exit(exit, signal) {
+	if (called) {
+		return;
+	}
+
+	called = true;
+
+	cbs.forEach(function (el) {
+		el();
+	});
+
+	if (exit === true) {
+		process.exit(128 + signal);
+	}
+};
+
+module.exports = function (cb) {
+	cbs.push(cb);
+
+	if (cbs.length === 1) {
+		process.once('exit', exit);
+		process.once('SIGINT', exit.bind(null, true, 2));
+		process.once('SIGTERM', exit.bind(null, true, 15));
+	}
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (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.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..c5b5723
--- /dev/null
+++ b/package.json
@@ -0,0 +1,39 @@
+{
+  "name": "exit-hook",
+  "version": "1.1.1",
+  "description": "Run some code when the process exits",
+  "license": "MIT",
+  "repository": "sindresorhus/exit-hook",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "http://sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "node test.js"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "exit",
+    "quit",
+    "process",
+    "hook",
+    "graceful",
+    "handler",
+    "shutdown",
+    "sigterm",
+    "sigint",
+    "terminate",
+    "kill",
+    "stop",
+    "event"
+  ],
+  "devDependencies": {
+    "ava": "0.0.4"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..4dc64b9
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,40 @@
+# exit-hook [![Build Status](https://travis-ci.org/sindresorhus/exit-hook.svg?branch=master)](https://travis-ci.org/sindresorhus/exit-hook)
+
+> Run some code when the process exits
+
+The `process.on('exit')` event doesn't catch all the ways a process can exit.
+
+Useful for cleaning up.
+
+
+## Install
+
+```sh
+$ npm install --save exit-hook
+```
+
+
+## Usage
+
+```js
+var exitHook = require('exit-hook');
+
+exitHook(function () {
+	console.log('exiting');
+});
+
+// you can add multiple hooks, even across files
+exitHook(function () {
+	console.log('exiting 2');
+});
+
+throw new Error('unicorns');
+
+//=> exiting
+//=> exiting 2
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..e92fb06
--- /dev/null
+++ b/test.js
@@ -0,0 +1,17 @@
+'use strict';
+var test = require('ava');
+var exitHook = require('./');
+
+test(function (t) {
+	t.plan(2);
+
+	exitHook(function () {
+		t.assert(true);
+	});
+
+	exitHook(function () {
+		t.assert(true);
+	});
+
+	process.exit();
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-exit-hook.git



More information about the Pkg-javascript-commits mailing list