slugcopy 1.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.
- package/.gitattributes +1 -0
- package/README.md +33 -0
- package/cli.js +59 -0
- package/license +21 -0
- package/package.json +50 -0
- package/test.js +27 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# slugcopy
|
|
2
|
+
Slugify strings and copy to clipboard
|
|
3
|
+
|
|
4
|
+
## Install
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
$ npm install --global slugcopy
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
$ slugcopy --help
|
|
14
|
+
|
|
15
|
+
Usage
|
|
16
|
+
$ slugcopy <string>
|
|
17
|
+
|
|
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
|
+
|
|
24
|
+
Examples
|
|
25
|
+
$ slugcopy Déjà Vu!
|
|
26
|
+
deja-vu
|
|
27
|
+
$ slugcopy Like a Boss --no-lowercase --separator='_'
|
|
28
|
+
Like_a_Boss
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Related
|
|
32
|
+
|
|
33
|
+
- [slugify-cli](https://github.com/sindresorhus/slugify-cli) - Motivation for this project
|
package/cli.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import meow from "meow";
|
|
3
|
+
import slugify from "@sindresorhus/slugify";
|
|
4
|
+
import cp from "copy-paste";
|
|
5
|
+
|
|
6
|
+
const cli = meow(
|
|
7
|
+
`
|
|
8
|
+
Usage
|
|
9
|
+
$ slugcopy <string>
|
|
10
|
+
|
|
11
|
+
Options
|
|
12
|
+
--separator=<string> Word separator [Default: -]
|
|
13
|
+
--no-lowercase Don’t make the slug lowercase [Default: true]
|
|
14
|
+
--no-decamelize Don’t convert camelCase to separate words [Default: true]
|
|
15
|
+
--preserve-leading-underscore If your string starts with an underscore, it will be preserved in the slugified string [Default: false]
|
|
16
|
+
--no-copy Don't copy the slug to the clipboard [Default: false]
|
|
17
|
+
|
|
18
|
+
Examples
|
|
19
|
+
$ slugcopy Déjà Vu!
|
|
20
|
+
deja-vu
|
|
21
|
+
$ slugcopy Like a Boss --no-lowercase --separator='_'
|
|
22
|
+
Like_a_Boss
|
|
23
|
+
`,
|
|
24
|
+
{
|
|
25
|
+
importMeta: import.meta,
|
|
26
|
+
flags: {
|
|
27
|
+
separator: {
|
|
28
|
+
type: "string",
|
|
29
|
+
},
|
|
30
|
+
lowercase: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
default: true,
|
|
33
|
+
},
|
|
34
|
+
decamelize: {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
default: true,
|
|
37
|
+
},
|
|
38
|
+
preserveLeadingUnderscore: {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
copy: {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
default: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const text = cli.input.join(" ");
|
|
51
|
+
const output = slugify(text, cli.flags);
|
|
52
|
+
|
|
53
|
+
console.log(output);
|
|
54
|
+
|
|
55
|
+
if (cli.flags.copy) {
|
|
56
|
+
cp.copy(output, function () {
|
|
57
|
+
console.log("Copied to clipboard");
|
|
58
|
+
});
|
|
59
|
+
}
|
package/license
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Imran Pollob <polboy777@gmail.com> (https://www.imranpollob.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "slugcopy",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Slugify strings and copy to clipboard",
|
|
5
|
+
"main": "cli.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "ava"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"bin": {
|
|
11
|
+
"slugcopy": "./cli.js"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=12"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/imranpollob/slugcopy.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cli",
|
|
22
|
+
"slug",
|
|
23
|
+
"slugify",
|
|
24
|
+
"slugify-copy",
|
|
25
|
+
"slugify-and-copy",
|
|
26
|
+
"url",
|
|
27
|
+
"urlify",
|
|
28
|
+
"urlify-copy",
|
|
29
|
+
"urlify-and-copy",
|
|
30
|
+
"decamelize",
|
|
31
|
+
"url",
|
|
32
|
+
"safe-url",
|
|
33
|
+
"url-safe"
|
|
34
|
+
],
|
|
35
|
+
"author": "Imran Pollob",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/imranpollob/slugcopy/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/imranpollob/slugcopy#readme",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@sindresorhus/slugify": "^2.2.1",
|
|
43
|
+
"copy-paste": "^1.5.3",
|
|
44
|
+
"meow": "^13.2.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"ava": "^6.1.3",
|
|
48
|
+
"execa": "^9.2.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/test.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import {execa} from 'execa';
|
|
3
|
+
|
|
4
|
+
test('main', async t => {
|
|
5
|
+
const {stdout} = await execa('./cli.js', ['Déjà Vu!']);
|
|
6
|
+
t.is(stdout.split("\n")[0], 'deja-vu');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('separator', async t => {
|
|
10
|
+
const {stdout} = await execa('./cli.js', ['Like a Boss', '--separator=_']);
|
|
11
|
+
t.is(stdout.split("\n")[0], 'like_a_boss');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('lowercase', async t => {
|
|
15
|
+
const {stdout} = await execa('./cli.js', ['Déjà Vu!', '--no-lowercase']);
|
|
16
|
+
t.is(stdout.split("\n")[0], 'Deja-Vu');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('decamelize', async t => {
|
|
20
|
+
const {stdout} = await execa('./cli.js', ['fooBar', '--no-decamelize']);
|
|
21
|
+
t.is(stdout.split("\n")[0], 'foobar');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('preserve-leading-underscore', async t => {
|
|
25
|
+
const {stdout} = await execa('./cli.js', ['_foo_bar', '--preserve-leading-underscore']);
|
|
26
|
+
t.is(stdout.split("\n")[0], '_foo-bar');
|
|
27
|
+
});
|