pax_global_header00006660000000000000000000000064131302620470014510gustar00rootroot0000000000000052 comment=a83cd9d8ad6560dadaa85ae3e677e5a3b58e3ee4 path-type-3.0.0/000077500000000000000000000000001313026204700134235ustar00rootroot00000000000000path-type-3.0.0/.editorconfig000066400000000000000000000002571313026204700161040ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 path-type-3.0.0/.gitattributes000066400000000000000000000000351313026204700163140ustar00rootroot00000000000000* text=auto *.js text eol=lf path-type-3.0.0/.gitignore000066400000000000000000000000271313026204700154120ustar00rootroot00000000000000node_modules yarn.lock path-type-3.0.0/.npmrc000066400000000000000000000000231313026204700145360ustar00rootroot00000000000000package-lock=false path-type-3.0.0/.travis.yml000066400000000000000000000000631313026204700155330ustar00rootroot00000000000000language: node_js node_js: - '8' - '6' - '4' path-type-3.0.0/index.js000066400000000000000000000017351313026204700150760ustar00rootroot00000000000000'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]()) .catch(err => { if (err.code === 'ENOENT') { return false; } throw err; }); } function typeSync(fn, fn2, fp) { if (typeof fp !== 'string') { throw new TypeError(`Expected a string, got ${typeof fp}`); } try { return fs[fn](fp)[fn2](); } catch (err) { if (err.code === 'ENOENT') { return false; } throw err; } } 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'); path-type-3.0.0/license000066400000000000000000000021251313026204700147700ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (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. path-type-3.0.0/package.json000066400000000000000000000012331313026204700157100ustar00rootroot00000000000000{ "name": "path-type", "version": "3.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@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": "^3.0.0" }, "devDependencies": { "ava": "*", "xo": "*" } } path-type-3.0.0/readme.md000066400000000000000000000013051313026204700152010ustar00rootroot00000000000000# 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 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) path-type-3.0.0/symlink000077700000000000000000000000001313026204700163442test.jsustar00rootroot00000000000000path-type-3.0.0/test.js000066400000000000000000000012061313026204700147370ustar00rootroot00000000000000import 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')); }); test('return false if path doesn\'t exist - async', async t => { t.false(await m.file('unicorn')); }); test('return false if path doesn\'t exist - sync', t => { t.false(m.fileSync('unicorn')); });