utiller 1.0.290 → 1.0.291

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,6 @@ var _pdfParse = _interopRequireDefault(require("pdf-parse"));
28
28
  var _del = _interopRequireWildcard(require("del"));
29
29
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
30
30
  var _prompt = _interopRequireDefault(require("prompt"));
31
- var _nodeHtmlParser = require("node-html-parser");
32
31
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
33
32
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
34
33
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
@@ -179,10 +178,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
179
178
  return true;
180
179
  };
181
180
  if (!_fs["default"].existsSync(path)) return [];
181
+ var result = [];
182
182
  var entries = _fs["default"].readdirSync(path, {
183
183
  withFileTypes: true
184
184
  });
185
- var files = [];
186
185
  for (var _len3 = arguments.length, excludes = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
187
186
  excludes[_key3 - 2] = arguments[_key3];
188
187
  }
@@ -194,10 +193,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
194
193
  if (excludes.includes(entry.name)) continue;
195
194
  var fullPath = _path5["default"].join(path, entry.name);
196
195
  if (entry.isDirectory()) {
197
- files.push.apply(files, (0, _toConsumableArray2["default"])(this.findFilePathBy.apply(this, [fullPath, predicate].concat(excludes))));
196
+ result.push.apply(result, (0, _toConsumableArray2["default"])(this.findFilePathBy.apply(this, [fullPath, predicate].concat(excludes))));
198
197
  } else if (entry.isFile()) {
199
198
  var info = this.getPathInfo(fullPath);
200
- if (predicate(info)) files.push(info);
199
+ if (predicate(info)) result.push(info);
201
200
  }
202
201
  }
203
202
  } catch (err) {
@@ -205,7 +204,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
205
204
  } finally {
206
205
  _iterator.f();
207
206
  }
208
- return files;
207
+ return result;
209
208
  }
210
209
 
211
210
  /** 是一個存在的檔案 */
@@ -222,16 +221,14 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
222
221
  key: "renameFile",
223
222
  value: function renameFile(path) {
224
223
  var newName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fileName";
225
- if (!this.isPathExist(path) || !this.isFile(path)) {
226
- this.appendError("984521 path not exist or not a file path:".concat(path));
224
+ if (!this.isFile(path) || !newName) {
225
+ this.appendError("renameFile \u932F\u8AA4, path: ".concat(path, ", newName: ").concat(newName));
227
226
  return;
228
227
  }
229
- if (_lodash["default"].isEmpty(newName)) {
230
- this.appendError("984522,new name is empty");
231
- return;
232
- }
233
- var next = _path5["default"].join(this.getFileDirPath(path), "".concat(newName, ".").concat(this.getExtensionFromPath(path)));
234
- _fs["default"].renameSync(path, next);
228
+ var dir = _path5["default"].dirname(path);
229
+ var ext = _path5["default"].extname(path);
230
+ var newPath = _path5["default"].join(dir, "".concat(newName).concat(ext));
231
+ _fs["default"].renameSync(path, newPath);
235
232
  }
236
233
 
237
234
  //todo 應該要改成class
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.290",
3
+ "version": "1.0.291",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "configerer": "^1.0.11",
14
- "utiller": "^1.0.289",
14
+ "utiller": "^1.0.290",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.12",
17
17
  "lodash": "^4.17.20",