@lsky/tools
Advanced tools
+116
-1
@@ -5,5 +5,18 @@ "use strict"; | ||
| exports.exec = void 0; | ||
| exports.isDirectory = isDirectory; | ||
| exports.isExist = isExist; | ||
| exports.isFile = isFile; | ||
| var _child_process = require("child_process"); | ||
| var _fs = _interopRequireDefault(require("fs")); | ||
| var _util = _interopRequireDefault(require("util")); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
| function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
| function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
@@ -47,2 +60,104 @@ | ||
| exports.exec = exec; | ||
| exports.exec = exec; | ||
| function isFile(_x) { | ||
| return _isFile.apply(this, arguments); | ||
| } | ||
| function _isFile() { | ||
| _isFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(p) { | ||
| var stat; | ||
| return regeneratorRuntime.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| _context.prev = 0; | ||
| _context.next = 3; | ||
| return _util.default.promisify(_fs.default.stat)(p); | ||
| case 3: | ||
| stat = _context.sent; | ||
| return _context.abrupt("return", !!stat.isFile()); | ||
| case 7: | ||
| _context.prev = 7; | ||
| _context.t0 = _context["catch"](0); | ||
| return _context.abrupt("return", false); | ||
| case 10: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee, null, [[0, 7]]); | ||
| })); | ||
| return _isFile.apply(this, arguments); | ||
| } | ||
| function isDirectory(_x2) { | ||
| return _isDirectory.apply(this, arguments); | ||
| } | ||
| function _isDirectory() { | ||
| _isDirectory = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(p) { | ||
| var stat; | ||
| return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
| while (1) { | ||
| switch (_context2.prev = _context2.next) { | ||
| case 0: | ||
| _context2.prev = 0; | ||
| _context2.next = 3; | ||
| return _util.default.promisify(_fs.default.stat)(p); | ||
| case 3: | ||
| stat = _context2.sent; | ||
| return _context2.abrupt("return", !!stat.isDirectory()); | ||
| case 7: | ||
| _context2.prev = 7; | ||
| _context2.t0 = _context2["catch"](0); | ||
| return _context2.abrupt("return", false); | ||
| case 10: | ||
| case "end": | ||
| return _context2.stop(); | ||
| } | ||
| } | ||
| }, _callee2, null, [[0, 7]]); | ||
| })); | ||
| return _isDirectory.apply(this, arguments); | ||
| } | ||
| function isExist(_x3) { | ||
| return _isExist.apply(this, arguments); | ||
| } | ||
| function _isExist() { | ||
| _isExist = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(p) { | ||
| var stat; | ||
| return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
| while (1) { | ||
| switch (_context3.prev = _context3.next) { | ||
| case 0: | ||
| _context3.prev = 0; | ||
| _context3.next = 3; | ||
| return _util.default.promisify(_fs.default.stat)(p); | ||
| case 3: | ||
| stat = _context3.sent; | ||
| return _context3.abrupt("return", stat.isFile() || stat.isDirectory()); | ||
| case 7: | ||
| _context3.prev = 7; | ||
| _context3.t0 = _context3["catch"](0); | ||
| return _context3.abrupt("return", false); | ||
| case 10: | ||
| case "end": | ||
| return _context3.stop(); | ||
| } | ||
| } | ||
| }, _callee3, null, [[0, 7]]); | ||
| })); | ||
| return _isExist.apply(this, arguments); | ||
| } |
+1
-1
| { | ||
| "name": "@lsky/tools", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:lsky-walt/tools.git", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
34506
12.29%666
16.84%2
100%