redput 1.8.0 → 1.9.0

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/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.08.30, v1.9.0
2
+
3
+ feature:
4
+ - 2ea4171 redput: add -v, --version
5
+
1
6
  2023.08.28, v1.8.0
2
7
 
3
8
  feature:
package/bin/redput.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import process from 'node:process';
3
4
  import {redput} from '../lib/redput.js';
4
5
 
5
6
  const {GITHUB_TOKEN} = process.env;
@@ -10,6 +11,12 @@ if (!url) {
10
11
  process.exit(1);
11
12
  }
12
13
 
14
+ if (url === '-v' || url === '--version') {
15
+ const {version} = await import('../lib/version.js');
16
+ console.log(await version());
17
+ process.exit();
18
+ }
19
+
13
20
  const [error, result] = await redput(url, {
14
21
  token: GITHUB_TOKEN,
15
22
  });
package/lib/version.js ADDED
@@ -0,0 +1,11 @@
1
+ import {readFile} from 'node:fs/promises';
2
+
3
+ const {parse} = JSON;
4
+ const {pathname} = new URL('../package.json', import.meta.url);
5
+
6
+ export const version = async () => {
7
+ const data = await readFile(pathname, 'utf8');
8
+ const {version} = parse(data);
9
+
10
+ return `v${version}`;
11
+ };
@@ -9,6 +9,7 @@ import {
9
9
  join,
10
10
  } from 'node:path';
11
11
  import rendy from 'rendy';
12
+ import process from 'node:process';
12
13
  import {addRule} from './add-rule/add-rule.js';
13
14
  import {insertTest} from './insert-test/insert-test.js';
14
15
  import {prepareRule} from './prepare-rule/prepare-rule.js';
@@ -9,6 +9,7 @@ import {
9
9
  join,
10
10
  } from 'node:path';
11
11
  import rendy from 'rendy';
12
+ import process from 'node:process';
12
13
 
13
14
  export const writeRule = async (name, data) => {
14
15
  await mkdir(`./lib`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redput",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "CLI tool to convert source from 🐊Putout Editor to files",
5
5
  "main": "lib/redput.js",
6
6
  "bin": {