nmew 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/LICENSE +22 -0
- package/README.md +35 -0
- package/package.json +14 -0
- package/src/nmew.js +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 waxodium
|
|
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.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Usage
|
|
2
|
+
nmew [FILE]
|
|
3
|
+
It's that simple. `nmew` concatenate files to standard output as **UTF-8**. The __[FILE]__ argument accepts both absolute and relative file paths, and supports file path formats for both Unix-like (example: `/home/Alice/File.txt`) and Windows operating (e.g., `C:\Users\Bobby\File.txt`) systems.
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
npm install -g nmew
|
|
7
|
+
|
|
8
|
+
# About
|
|
9
|
+
Why nmew should be recognized among Node.js beginners?
|
|
10
|
+
|
|
11
|
+
Because it demonstrates core CLI and Node.js concepts by presenting them in a clear, block-by-block format that makes each part easy to read and understand. Featuring:
|
|
12
|
+
* Shebang for Node.js scripts
|
|
13
|
+
* Node.js core modules `node:fs, node:os`
|
|
14
|
+
* Basic terminal styling with Node.js
|
|
15
|
+
* Arguement handling
|
|
16
|
+
* String replacement with Regex
|
|
17
|
+
* Modular error handling
|
|
18
|
+
* Conditional CLI behavior
|
|
19
|
+
* Async Function Usage
|
|
20
|
+
* Command-Line Arguments `process.argv[2]`
|
|
21
|
+
|
|
22
|
+
# Features
|
|
23
|
+
Display the description and the lore of nmew.
|
|
24
|
+
|
|
25
|
+
nmew --info
|
|
26
|
+
|
|
27
|
+
Prints out an adorable little ASCII cat
|
|
28
|
+
|
|
29
|
+
nmew --cat
|
|
30
|
+
|
|
31
|
+
# Credits
|
|
32
|
+
As this is an experimental project, I would like to respectfully acknowledge that the modular part of the code, `const untildify`, is adapted from the [30secondsofcode.org](https://www.30secondsofcode.org/js/s/convert-to-absolute-path/) article and modified for use in the current binary.
|
|
33
|
+
|
|
34
|
+
Link to credited NPM registry
|
|
35
|
+
[30-seconds-of-code#untildify](https://www.npmjs.com/package/30-seconds-of-code#untildify)
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nmew",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "nmew. Concatenate files to standard output built with NodeJS experimentally. Developed through personal exercise and studies",
|
|
5
|
+
"main": "s.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"nmew": "./src/nmew.js"
|
|
8
|
+
},
|
|
9
|
+
"author": "waxory",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/nmew.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require("node:fs")
|
|
3
|
+
const os = require("node:os")
|
|
4
|
+
const reset = "\x1b[0m"
|
|
5
|
+
const red = "\x1b[31m"
|
|
6
|
+
const bold = "\x1b[1m"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const untildify = str => {
|
|
10
|
+
if (typeof str !== 'string') {
|
|
11
|
+
console.error(`[${red}${bold}nmew${reset}] Invalid Arguement! Try 'nmew --info'`)
|
|
12
|
+
process.exit(1)
|
|
13
|
+
} else if (typeof str === 'string') {
|
|
14
|
+
return str.replace(/^~($|\/|\\)/, `${os.homedir()}$1`)
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const info = `Usage 'nmew [FILE]'
|
|
19
|
+
|
|
20
|
+
Concatenate files to standard output as UTF-8.
|
|
21
|
+
[FILE] argument accepts both absolute and relative
|
|
22
|
+
file paths, and supports file path formats for
|
|
23
|
+
both Unix-like (example: home/Alice/File.txt)
|
|
24
|
+
and Windows operating (e.g., C:\\Users\\Bobby\\File.txt) systems.
|
|
25
|
+
|
|
26
|
+
# OPTIONS
|
|
27
|
+
,--info Display this info looking thing
|
|
28
|
+
,--cat Prints out an adorable little ASCII cat (^o~o^)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Why the heck is it named nmew?
|
|
32
|
+
> nmew ~ (n) Node.js (mew) A shorthand word of Meow.
|
|
33
|
+
Inspired by command: cat
|
|
34
|
+
cat goes Meow. So that gives off a similar relation
|
|
35
|
+
between nmew and cat :)
|
|
36
|
+
`
|
|
37
|
+
const cuteCat = [
|
|
38
|
+
'',
|
|
39
|
+
' /\\_/\\',
|
|
40
|
+
'( o.o )',
|
|
41
|
+
' > ^ <',
|
|
42
|
+
'/ \\',
|
|
43
|
+
'(# #)',
|
|
44
|
+
' 2___2',
|
|
45
|
+
'',
|
|
46
|
+
' Meowy!',
|
|
47
|
+
'',
|
|
48
|
+
' His name is Owen',
|
|
49
|
+
''
|
|
50
|
+
].map(function (l) {
|
|
51
|
+
return l;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
async function paw(path) {
|
|
55
|
+
const data = path;
|
|
56
|
+
const parsed = untildify(data)
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
if (parsed === "--info") {
|
|
60
|
+
console.log(info)
|
|
61
|
+
} else if (parsed === "--cat") {
|
|
62
|
+
console.log(cuteCat.join('\n'));
|
|
63
|
+
} else {
|
|
64
|
+
const fileData = fs.readFileSync(parsed, 'utf8');
|
|
65
|
+
console.log(fileData);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} catch (err) {
|
|
69
|
+
if (err.code === "ENOENT") { console.error(`[${red}${bold}nmew${reset}] Path not found!`)}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const ManHowDoINameThis = process.argv[2]
|
|
75
|
+
paw(ManHowDoINameThis)
|