@ffflorian/xkcdjs 3.4.4 → 3.4.5
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.
- package/dist/cli.js +8 -8
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -43,15 +43,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const node_fs_1 = require("node:fs");
|
|
46
48
|
const commander_1 = require("commander");
|
|
47
|
-
const
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
|
+
const package_json_1 = require("../package.json");
|
|
49
50
|
const _1 = require("./");
|
|
50
51
|
function init() {
|
|
51
52
|
return __awaiter(this, arguments, void 0, function* (dir = '.') {
|
|
52
53
|
const resolvedPath = path.resolve(dir);
|
|
53
54
|
try {
|
|
54
|
-
yield
|
|
55
|
+
yield node_fs_1.promises.access(resolvedPath, node_fs_1.constants.F_OK | node_fs_1.constants.R_OK);
|
|
55
56
|
const xkcd = new _1.XKCD();
|
|
56
57
|
return [resolvedPath, xkcd];
|
|
57
58
|
}
|
|
@@ -65,16 +66,15 @@ function save(filePath, imageResult) {
|
|
|
65
66
|
const { data, num, safe_title } = imageResult;
|
|
66
67
|
const extension = data.mimeType ? data.mimeType.replace('image/', '') : 'png';
|
|
67
68
|
const resolvedFilePath = path.resolve(filePath, `xkcd #${num} - ${safe_title}.${extension}`);
|
|
68
|
-
yield
|
|
69
|
+
yield node_fs_1.promises.writeFile(resolvedFilePath, data.data);
|
|
69
70
|
console.info(`Saved image to "${resolvedFilePath}".`);
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
|
-
const { description, name, version } = require('../package.json');
|
|
73
73
|
commander_1.program.on('command:*', () => commander_1.program.help());
|
|
74
74
|
commander_1.program
|
|
75
|
-
.name(name.replace(/^@[^/]+\//, ''))
|
|
76
|
-
.version(version, '-v, --version')
|
|
77
|
-
.description(description)
|
|
75
|
+
.name(package_json_1.name.replace(/^@[^/]+\//, ''))
|
|
76
|
+
.version(package_json_1.version, '-v, --version')
|
|
77
|
+
.description(package_json_1.description)
|
|
78
78
|
.option('-o, --output <dir>', 'Specify the output directory', path.resolve('.'));
|
|
79
79
|
commander_1.program
|
|
80
80
|
.command('latest')
|
package/package.json
CHANGED