[Pkg-javascript-commits] [node-path-type] 01/03: Import Upstream version 2.0.0
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Wed Oct 26 06:41:49 UTC 2016
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository node-path-type.
commit 0b2f265908d5f21bd57a28efdb734718855fb0fc
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Wed Oct 26 11:50:11 2016 +0530
Import Upstream version 2.0.0
---
.editorconfig | 12 ++++++++++++
.gitattributes | 2 ++
.gitignore | 1 +
.travis.yml | 4 ++++
index.js | 26 ++++++++++++++++++++++++++
license | 21 +++++++++++++++++++++
package.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
readme.md | 42 ++++++++++++++++++++++++++++++++++++++++++
symlink | 1 +
test.js | 26 ++++++++++++++++++++++++++
10 files changed, 183 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..391f0a4
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+* text=auto
+*.js text eol=lf
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..97519af
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - '6'
+ - '4'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..4ac9dd9
--- /dev/null
+++ b/index.js
@@ -0,0 +1,26 @@
+'use strict';
+const fs = require('fs');
+const pify = require('pify');
+
+function type(fn, fn2, fp) {
+ if (typeof fp !== 'string') {
+ return Promise.reject(new TypeError(`Expected a string, got ${typeof fp}`));
+ }
+
+ return pify(fs[fn])(fp).then(stats => stats[fn2]());
+}
+
+function typeSync(fn, fn2, fp) {
+ if (typeof fp !== 'string') {
+ throw new TypeError(`Expected a string, got ${typeof fp}`);
+ }
+
+ return fs[fn](fp)[fn2]();
+}
+
+exports.file = type.bind(null, 'stat', 'isFile');
+exports.dir = type.bind(null, 'stat', 'isDirectory');
+exports.symlink = type.bind(null, 'lstat', 'isSymbolicLink');
+exports.fileSync = typeSync.bind(null, 'statSync', 'isFile');
+exports.dirSync = typeSync.bind(null, 'statSync', 'isDirectory');
+exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink');
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..54336f3
--- /dev/null
+++ b/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "path-type",
+ "version": "2.0.0",
+ "description": "Check if a path is a file, directory, or symlink",
+ "license": "MIT",
+ "repository": "sindresorhus/path-type",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus at gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "path",
+ "fs",
+ "type",
+ "is",
+ "check",
+ "directory",
+ "dir",
+ "file",
+ "filepath",
+ "symlink",
+ "symbolic",
+ "link",
+ "stat",
+ "stats",
+ "filesystem"
+ ],
+ "dependencies": {
+ "pify": "^2.0.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "xo": {
+ "esnext": true
+ }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..b1ea61f
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,42 @@
+# path-type [![Build Status](https://travis-ci.org/sindresorhus/path-type.svg?branch=master)](https://travis-ci.org/sindresorhus/path-type)
+
+> Check if a path is a file, directory, or symlink
+
+
+## Install
+
+```
+$ npm install --save path-type
+```
+
+
+## Usage
+
+```js
+const pathType = require('path-type');
+
+pathType.file('package.json').then(isFile => {
+ console.log(isFile);
+ //=> true
+})
+```
+
+
+## API
+
+### .file(path)
+### .dir(path)
+### .symlink(path)
+
+Returns a `Promise` for a `boolean` of whether the path is the checked type.
+
+### .fileSync(path)
+### .dirSync(path)
+### .symlinkSync(path)
+
+Returns a `boolean` of whether the path is the checked type.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/symlink b/symlink
new file mode 120000
index 0000000..602eb8e
--- /dev/null
+++ b/symlink
@@ -0,0 +1 @@
+test.js
\ No newline at end of file
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..75f07a5
--- /dev/null
+++ b/test.js
@@ -0,0 +1,26 @@
+import test from 'ava';
+import m from './';
+
+test('.file()', async t => {
+ t.true(await m.file('package.json'));
+});
+
+test('.dir()', async t => {
+ t.true(await m.dir('.'));
+});
+
+test('.symlink()', async t => {
+ t.true(await m.symlink('symlink'));
+});
+
+test('.fileSync()', t => {
+ t.true(m.fileSync('package.json'));
+});
+
+test('.dirSync()', t => {
+ t.true(m.dirSync('.'));
+});
+
+test('.symlinkSync()', t => {
+ t.true(m.symlinkSync('symlink'));
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-path-type.git
More information about the Pkg-javascript-commits
mailing list