[Pkg-javascript-commits] [node-path-exists] 01/05: Import Upstream version 3.0.0
Sruthi Chandran
srud-guest at moszumanska.debian.org
Tue Oct 25 11:32:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
srud-guest pushed a commit to branch master
in repository node-path-exists.
commit c5357c4617d70982f380556439de02ce4b80d1a1
Author: Sruthi <srud at disroot.org>
Date: Tue Oct 25 16:42:14 2016 +0530
Import Upstream version 3.0.0
---
.editorconfig | 12 ++++++++++++
.gitattributes | 1 +
.gitignore | 1 +
.travis.yml | 5 +++++
index.js | 17 +++++++++++++++++
license | 21 +++++++++++++++++++++
package.json | 40 ++++++++++++++++++++++++++++++++++++++++
readme.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
test.js | 12 ++++++++++++
9 files changed, 159 insertions(+)
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+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
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/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b18bae5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+sudo: false
+language: node_js
+node_js:
+ - '6'
+ - '4'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..16ae60a
--- /dev/null
+++ b/index.js
@@ -0,0 +1,17 @@
+'use strict';
+const fs = require('fs');
+
+module.exports = fp => new Promise(resolve => {
+ fs.access(fp, err => {
+ resolve(!err);
+ });
+});
+
+module.exports.sync = fp => {
+ try {
+ fs.accessSync(fp);
+ return true;
+ } catch (err) {
+ return false;
+ }
+};
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..efd5626
--- /dev/null
+++ b/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "path-exists",
+ "version": "3.0.0",
+ "description": "Check if a path exists",
+ "license": "MIT",
+ "repository": "sindresorhus/path-exists",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus at gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "path",
+ "exists",
+ "exist",
+ "file",
+ "filepath",
+ "fs",
+ "filesystem",
+ "file-system",
+ "access",
+ "stat"
+ ],
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "xo": {
+ "esnext": true
+ }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..1b65fa7
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,50 @@
+# path-exists [![Build Status](https://travis-ci.org/sindresorhus/path-exists.svg?branch=master)](https://travis-ci.org/sindresorhus/path-exists)
+
+> Check if a path exists
+
+Because [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), but there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
+
+Never use this before handling a file though:
+
+> In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there.
+
+
+## Install
+
+```
+$ npm install --save path-exists
+```
+
+
+## Usage
+
+```js
+// foo.js
+const pathExists = require('path-exists');
+
+pathExists('foo.js').then(exists => {
+ console.log(exists);
+ //=> true
+});
+```
+
+
+## API
+
+### pathExists(path)
+
+Returns a promise for a boolean of whether the path exists.
+
+### pathExists.sync(path)
+
+Returns a boolean of whether the path exists.
+
+
+## Related
+
+- [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..e726a11
--- /dev/null
+++ b/test.js
@@ -0,0 +1,12 @@
+import test from 'ava';
+import m from './';
+
+test('async', async t => {
+ t.true(await m('test.js'));
+ t.false(await m('fail'));
+});
+
+test('sync', t => {
+ t.true(m.sync('test.js'));
+ t.false(m.sync('fail'));
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-path-exists.git
More information about the Pkg-javascript-commits
mailing list