stdin-glob 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.
@@ -0,0 +1,23 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: NPM Package
5
+
6
+ on:
7
+ push:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: '20'
18
+
19
+ - run: npm install
20
+
21
+ - uses: JS-DevTools/npm-publish@v3
22
+ with:
23
+ token: ${{ secrets.NPM_TOKEN }}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rodny Estrada
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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # stdin-glob
2
+
3
+ A glob cli to find and print files quickly including reading from stdin so it can be piped to other unix apps.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const commander_1 = require("commander");
7
+ const package_json_1 = require("../package.json");
8
+ const promises_1 = require("fs/promises");
9
+ const fast_glob_1 = __importDefault(require("fast-glob"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const program = new commander_1.Command();
12
+ program
13
+ .name('stdin-glob')
14
+ .description('Expand glob patterns and output file contents and paths')
15
+ .version(package_json_1.version)
16
+ .option('--no-content', 'Do not show file contents, only list matching paths')
17
+ .option('--absolute', 'Show the absolute path for entries')
18
+ .argument('[patterns...]', 'Glob patterns to match files')
19
+ .action(async (patterns, options) => {
20
+ if (patterns.length === 0) {
21
+ console.error('Error: No patterns provided.');
22
+ process.exit(1);
23
+ }
24
+ //expand glob
25
+ const files = await (0, fast_glob_1.default)(patterns, {
26
+ onlyFiles: true,
27
+ absolute: options.absolute ?? false,
28
+ });
29
+ if (files.length === 0) {
30
+ console.error('No files matched the given patterns.');
31
+ process.exit(1);
32
+ }
33
+ for (const file of files) {
34
+ if (options.content)
35
+ await printFileWithFormat(file);
36
+ else
37
+ console.log(file);
38
+ }
39
+ });
40
+ program.parse(process.argv);
41
+ /**
42
+ * Print files with format markdown
43
+ */
44
+ const printFileWithFormat = async (filePath) => {
45
+ try {
46
+ const content = await (0, promises_1.readFile)(filePath, 'utf-8');
47
+ console.log('```' + path_1.default.extname(filePath).replace('.', ''));
48
+ console.log(`// ${filePath}`);
49
+ console.log();
50
+ console.log(content);
51
+ console.log('```');
52
+ console.log();
53
+ }
54
+ catch (e) {
55
+ console.error(`Error reading file ${filePath}:`, e);
56
+ }
57
+ };
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,yCAAoC;AACpC,kDAA0C;AAC1C,0CAAuC;AACvC,0DAA6B;AAC7B,gDAAwB;AAOxB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,yDAAyD,CAAC;KACtE,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,cAAc,EAAE,qDAAqD,CAAC;KAC7E,MAAM,CAAC,YAAY,EAAE,oCAAoC,CAAC;KAC1D,QAAQ,CAAC,eAAe,EAAE,8BAA8B,CAAC;KACzD,MAAM,CAAC,KAAK,EAAE,QAAkB,EAAE,OAAgB,EAAE,EAAE;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,aAAa;IACb,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAI,EAAC,QAAQ,EAAE;QACjC,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,KAAK;KACpC,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,CAAC,OAAO;YAAE,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC;;YAChD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,mBAAmB,GAAG,KAAK,EAAE,QAAgB,EAAE,EAAE;IACrD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sBAAsB,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "stdin-glob",
3
+ "version": "1.0.0",
4
+ "description": "Expand glob patterns and output file contents, with support for reading patterns from stdin",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "stdin-glob": "./dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepare": "npm run build",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "keywords": [
16
+ "glob",
17
+ "stdin",
18
+ "cli",
19
+ "typescript",
20
+ "fast-glob"
21
+ ],
22
+ "author": "Rodny Estrada<rrodnyestrada1@gmail.com>",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/rodnye/stdin-glob.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/rodnye/stdin-glob/issues"
30
+ },
31
+ "homepage": "https://github.com/rodnye/stdin-glob#readme",
32
+ "dependencies": {
33
+ "commander": "^11.1.0",
34
+ "fast-glob": "^3.3.3"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^25.3.3",
38
+ "typescript": "^5.9.3"
39
+ }
40
+ }
package/src/index.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { Command } from 'commander';
2
+ import { version } from '../package.json';
3
+ import { readFile } from 'fs/promises';
4
+ import glob from 'fast-glob';
5
+ import path from 'path';
6
+
7
+ interface Options {
8
+ content?: boolean;
9
+ absolute?: boolean;
10
+ }
11
+
12
+ const program = new Command();
13
+
14
+ program
15
+ .name('stdin-glob')
16
+ .description('Expand glob patterns and output file contents and paths')
17
+ .version(version)
18
+ .option('--no-content', 'Do not show file contents, only list matching paths')
19
+ .option('--absolute', 'Show the absolute path for entries')
20
+ .argument('[patterns...]', 'Glob patterns to match files')
21
+ .action(async (patterns: string[], options: Options) => {
22
+ if (patterns.length === 0) {
23
+ console.error('Error: No patterns provided.');
24
+ process.exit(1);
25
+ }
26
+
27
+ //expand glob
28
+ const files = await glob(patterns, {
29
+ onlyFiles: true,
30
+ absolute: options.absolute ?? false,
31
+ });
32
+
33
+ if (files.length === 0) {
34
+ console.error('No files matched the given patterns.');
35
+ process.exit(1);
36
+ }
37
+
38
+ for (const file of files) {
39
+ if (options.content) await printFileWithFormat(file);
40
+ else console.log(file);
41
+ }
42
+ });
43
+
44
+ program.parse(process.argv);
45
+
46
+ /**
47
+ * Print files with format markdown
48
+ */
49
+ const printFileWithFormat = async (filePath: string) => {
50
+ try {
51
+ const content = await readFile(filePath, 'utf-8');
52
+ console.log('```' + path.extname(filePath).replace('.', ''));
53
+ console.log(`// ${filePath}`);
54
+ console.log();
55
+ console.log(content);
56
+ console.log('```');
57
+ console.log();
58
+ } catch (e) {
59
+ console.error(`Error reading file ${filePath}:`, e);
60
+ }
61
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "resolveJsonModule": true
16
+ },
17
+ "include": ["src/**/*"],
18
+ "exclude": ["node_modules", "dist"]
19
+ }