1 | "use strict";
|
2 |
|
3 | const pathUtil = require("path");
|
4 | const move = require("./move");
|
5 | const validate = require("./utils/validate");
|
6 |
|
7 | const validateInput = (methodName, path, newName) => {
|
8 | const methodSignature = `${methodName}(path, newName)`;
|
9 | validate.argument(methodSignature, "path", path, ["string"]);
|
10 | validate.argument(methodSignature, "newName", newName, ["string"]);
|
11 | };
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | const renameSync = (path, newName) => {
|
18 | const newPath = pathUtil.join(pathUtil.dirname(path), newName);
|
19 | move.sync(path, newPath);
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | const renameAsync = (path, newName) => {
|
27 | const newPath = pathUtil.join(pathUtil.dirname(path), newName);
|
28 | return move.async(path, newPath);
|
29 | };
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | exports.validateInput = validateInput;
|
36 | exports.sync = renameSync;
|
37 | exports.async = renameAsync;
|