You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

doc-snippets

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doc-snippets - npm Package Compare versions

Comparing version

to
0.2.0

22

build/cli.js

@@ -55,12 +55,16 @@ "use strict";

.argument("<outputDir>", "The output directory")
.action(function (snippetsDir, docsDir, outputDir) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, combine_1.combineDocsAndSnippets)(snippetsDir, docsDir, outputDir)];
case 1:
_a.sent();
return [2 /*return*/];
}
.option("-i, --ignore <ignoredPaths...>", "Ignore specified paths")
.action(function (snippetsDir, docsDir, outputDir, _a) {
var ignore = _a.ignore;
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, (0, combine_1.combineDocsAndSnippets)(snippetsDir, docsDir, outputDir, ignore)];
case 1:
_b.sent();
return [2 /*return*/];
}
});
});
}); });
});
return [4 /*yield*/, commander_1.program.parseAsync(argv)];

@@ -67,0 +71,0 @@ case 1:

@@ -1,1 +0,1 @@

export declare function combineDocsAndSnippets(snippetsDir: string, docsDir: string, outputDir: string): Promise<void>;
export declare function combineDocsAndSnippets(snippetsDir: string, docsDir: string, outputDir: string, ignorePaths?: string[]): Promise<void>;

@@ -70,3 +70,3 @@ "use strict";

var fs_1 = __importDefault(require("fs"));
function combineDocsAndSnippets(snippetsDir, docsDir, outputDir) {
function combineDocsAndSnippets(snippetsDir, docsDir, outputDir, ignorePaths) {
return __awaiter(this, void 0, void 0, function () {

@@ -83,3 +83,3 @@ var snippets;

console.log("- Extract Snippets");
return [4 /*yield*/, (0, extract_1.extractSnippets)(snippetsDir)];
return [4 /*yield*/, (0, extract_1.extractSnippets)(snippetsDir, ignorePaths)];
case 1:

@@ -86,0 +86,0 @@ snippets = _a.sent();

@@ -6,2 +6,2 @@ /**

*/
export declare function extractSnippets(dir: string): Promise<Record<string, string>>;
export declare function extractSnippets(dir: string, ignorePaths?: string[]): Promise<Record<string, string>>;

@@ -56,2 +56,3 @@ "use strict";

var fs_1 = __importDefault(require("fs"));
var ignore_1 = __importDefault(require("ignore"));
/**

@@ -62,5 +63,5 @@ * Extract snippets from all files within a directory

*/
function extractSnippets(dir) {
function extractSnippets(dir, ignorePaths) {
return __awaiter(this, void 0, void 0, function () {
var snippets;
var snippets, ignoreInstance;
return __generator(this, function (_a) {

@@ -70,3 +71,7 @@ switch (_a.label) {

snippets = {};
return [4 /*yield*/, searchAndExtractSnippetsFromDir(snippets, dir)];
ignoreInstance = (0, ignore_1.default)();
if (ignorePaths) {
ignoreInstance.add(ignorePaths);
}
return [4 /*yield*/, searchAndExtractSnippetsFromDir(snippets, dir, ignoreInstance)];
case 1:

@@ -80,3 +85,3 @@ _a.sent();

exports.extractSnippets = extractSnippets;
function searchAndExtractSnippetsFromDir(snippets, dir) {
function searchAndExtractSnippetsFromDir(snippets, dir, ignoreInstance) {
return __awaiter(this, void 0, void 0, function () {

@@ -119,2 +124,5 @@ var dirents, exts, filter, match, dirents_1, dirents_1_1, dirent, direntPath, e_1_1;

direntPath = path_1.default.join(dir, dirent.name);
if (ignoreInstance.test(direntPath).ignored) {
return [3 /*break*/, 6];
}
if (!(dirent.isFile() && match(dirent.name, exts))) return [3 /*break*/, 4];

@@ -127,3 +135,3 @@ return [4 /*yield*/, extractSnippetsFromFile(snippets, direntPath)];

if (!(dirent.isDirectory() && !match(dirent.name, filter))) return [3 /*break*/, 6];
return [4 /*yield*/, searchAndExtractSnippetsFromDir(snippets, direntPath)];
return [4 /*yield*/, searchAndExtractSnippetsFromDir(snippets, direntPath, ignoreInstance)];
case 5:

@@ -130,0 +138,0 @@ _b.sent();

{
"name": "doc-snippets",
"version": "0.1.1",
"version": "0.2.0",
"description": "Extract and inject snippets from code into markdown files",

@@ -51,4 +51,5 @@ "author": {

"commander": "^9.4.1",
"fs-extra": "^10.1.0"
"fs-extra": "^10.1.0",
"ignore": "^5.2.1"
}
}

@@ -45,2 +45,8 @@ # doc-snippets

#### Options
- `-i, --ignore <paths...>` - Ignore listed paths. Paths should be formatted according to the [gitignore spec 2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
### In your own code
If you want to use `doc-snippets` programatically, it offers two exported functions:

@@ -47,0 +53,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet