slugcopy 1.1.0 → 2.0.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.
Files changed (3) hide show
  1. package/README.md +52 -17
  2. package/cli.js +7 -4
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -1,35 +1,70 @@
1
1
  # slugcopy
2
- Slugify strings and copy to clipboard
2
+
3
+ > Slugify strings and copy them directly to your clipboard.
4
+
5
+ [![NPM Version](https://img.shields.io/npm/v/slugcopy)](https://www.npmjs.com/package/slugcopy)
6
+ [![License](https://img.shields.io/npm/l/slugcopy)](https://github.com/imranpollob/slugcopy/blob/master/license)
7
+
8
+ **slugcopy** is a lightweight command-line utility that converts any string into a URL-friendly slug and automatically copies the result to your system clipboard. It is built on top of the robust [`@sindresorhus/slugify`](https://github.com/sindresorhus/slugify) library.
9
+
10
+ ## Features
11
+
12
+ - 🚀 **Instant Copy**: Automatically puts the result in your clipboard.
13
+ - 🛠 **Customizable**: Choose your separator, handle camelCase, and more.
14
+ - 📦 **Modern**: Built with modern Node.js standards.
15
+ - 🌐 **International**: Handles special characters (e.g., `Déjà Vu!` -> `deja-vu`).
3
16
 
4
17
  ## Install
5
18
 
6
- ```
19
+ Requires [Node.js](https://nodejs.org/) 18 or higher.
20
+
21
+ ```bash
7
22
  npm install --global slugcopy
8
23
  ```
9
24
 
10
25
  ## Usage
11
26
 
27
+ ```bash
28
+ $ slugcopy <string>
12
29
  ```
13
- $ slugcopy --help
14
30
 
15
- Usage
16
- $ slugcopy <string>
31
+ ## Options
17
32
 
18
- Options
19
- --separator=<string> Word separator [Default: -]
20
- --no-lowercase Don’t make the slug lowercase [Default: true]
21
- --no-decamelize Don’t convert camelCase to separate words [Default: true]
22
- --preserve-leading-underscore If your string starts with an underscore, it will be preserved in the slugified string [Default: false]
23
- --no-copy Don't copy the slug to the clipboard [Default: false]
33
+ | Option | Description | Default |
34
+ | :------------------------------ | :--------------------------------- | :------------------- |
35
+ | `--separator=<string>` | Character to separate words | `-` |
36
+ | `--no-lowercase` | Preserve original casing | `true` (lowercases) |
37
+ | `--no-decamelize` | Preserve camelCase as single words | `true` (decamelizes) |
38
+ | `--preserve-leading-underscore` | Keep leading underscores | `false` |
39
+ | `--no-copy` | Do not copy result to clipboard | `false` (copies) |
24
40
 
41
+ ## Examples
25
42
 
26
- Examples
27
- $ slugcopy Déjà Vu!
28
- deja-vu
29
- $ slugcopy Like a Boss --no-lowercase --separator='_'
30
- Like_a_Boss
43
+ **Basic Usage**
44
+ ```bash
45
+ $ slugcopy "Déjà Vu!"
46
+ # Output: deja-vu
47
+ # Clipboard: deja-vu
48
+ ```
49
+
50
+ **Custom Separator & Case Preservation**
51
+ ```bash
52
+ $ slugcopy "Like a Boss" --no-lowercase --separator='_'
53
+ # Output: Like_a_Boss
54
+ # Clipboard: Like_a_Boss
55
+ ```
56
+
57
+ **Skipping Clipboard Copy**
58
+ ```bash
59
+ $ slugcopy "Just Print This" --no-copy
60
+ # Output: just-print-this
61
+ # Clipboard: (unchanged)
31
62
  ```
32
63
 
33
64
  ## Related
34
65
 
35
- - [slugify-cli](https://github.com/sindresorhus/slugify-cli) - Motivation for this project
66
+ - [slugify-cli](https://github.com/sindresorhus/slugify-cli) - The original inspiration for this project.
67
+
68
+ ## License
69
+
70
+ MIT © [Imran Pollob](https://github.com/imranpollob)
package/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import meow from "meow";
3
3
  import slugify from "@sindresorhus/slugify";
4
- import cp from "copy-paste";
4
+ import clipboardy from "clipboardy";
5
5
 
6
6
  const cli = meow(
7
7
  `
@@ -47,13 +47,16 @@ const cli = meow(
47
47
  }
48
48
  );
49
49
 
50
+ if (cli.input.length === 0) {
51
+ cli.showHelp();
52
+ }
53
+
50
54
  const text = cli.input.join(" ");
51
55
  const output = slugify(text, cli.flags);
52
56
 
53
57
  console.log(output);
54
58
 
55
59
  if (cli.flags.copy) {
56
- cp.copy(output, function () {
57
- console.log("Copied to clipboard");
58
- });
60
+ clipboardy.writeSync(output);
61
+ console.log("Copied to clipboard");
59
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slugcopy",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Slugify strings and copy to clipboard",
5
5
  "main": "cli.js",
6
6
  "scripts": {
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "type": "module",
10
10
  "bin": {
11
- "slugcopy": "./cli.js"
11
+ "slugcopy": "cli.js"
12
12
  },
13
13
  "engines": {
14
- "node": ">=12"
14
+ "node": ">=18"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -39,12 +39,12 @@
39
39
  },
40
40
  "homepage": "https://github.com/imranpollob/slugcopy#readme",
41
41
  "dependencies": {
42
- "@sindresorhus/slugify": "^2.2.1",
43
- "copy-paste": "^1.5.3",
44
- "meow": "^13.2.0"
42
+ "@sindresorhus/slugify": "3.0.0",
43
+ "clipboardy": "5.0.2",
44
+ "meow": "14.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "ava": "^6.1.3",
48
- "execa": "^9.2.0"
47
+ "ava": "6.4.1",
48
+ "execa": "9.6.1"
49
49
  }
50
50
  }