New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-typedoc

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-typedoc - npm Package Compare versions

Comparing version 2.0.3 to 2.1.0

46

index.js

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

// Copyright (c) 2015 Rogier Schouten <rogier.schouten@gmail.com>
// License: ICS
// Copyright (c) 2015 Rogier Schouten <github@workingcode.ninja>
// License: ISC
"use strict";
var es = require("event-stream");
var gutil = require("gulp-util");
var PluginError = gutil.PluginError;
var typedocModule = require("typedoc");
const es = require("event-stream");
const gutil = require("gulp-util");
const PluginError = gutil.PluginError;
const typedocModule = require("typedoc");
var PLUGIN_NAME = "gulp-typedoc";
const PLUGIN_NAME = "gulp-typedoc";
function typedoc(options) {
var files = [];
const files = [];
options = options || {};

@@ -21,3 +21,3 @@

// end of stream, start typedoc
var stream = this;
const stream = this;

@@ -33,25 +33,27 @@ if (files.length === 0) {

// leaving the 'out' or 'version' option in causes typedoc error for some reason
var out = options.out;
const out = options.out;
delete options.out;
var json = options.json;
const json = options.json;
delete options.json;
var version = options.version;
const version = options.version;
delete options.version;
// reduce console logging
options.logger = function(message, level, newline) {
if (level === 3) {
gutil.log(gutil.colors.red(message));
}
if (!options.logger) {
// reduce console logging
options.logger = function(message, level, newline) {
if (level === 3) {
gutil.log(gutil.colors.red(message));
}
};
}
// typedoc instance
var app = new typedocModule.Application(options);
const app = new typedocModule.Application(options);
if (version) {
if (version && options.logger !== "none") {
gutil.log(app.toString());
}
try {
var src = app.expandInputFiles(files);
var project = app.convert(src);
const src = app.expandInputFiles(files);
const project = app.convert(src);
if (project) {

@@ -79,3 +81,3 @@ if (out) app.generateDocs(project, out);

});
};
}

@@ -82,0 +84,0 @@ module.exports = typedoc;

{
"name": "gulp-typedoc",
"version": "2.0.3",
"version": "2.1.0",
"description": "Gulp plugin for the TypeDoc typescript documentation tool.",

@@ -11,3 +11,3 @@ "repository": {

"scripts": {
"test": "node test/test.js"
"test": "mocha test/test.js"
},

@@ -27,6 +27,10 @@ "keywords": [

"event-stream": "^3.3.4",
"gulp-util": "^3.0.8"
"gulp-util": "^3.0.8",
"typedoc": "^0.8.0"
},
"devDependencies": {
"chai": "^4.1.2",
"fs-extra": "^4.0.1",
"gulp": "^3.9.1",
"mocha": "^3.5.0",
"rimraf": "^2.6.1"

@@ -33,0 +37,0 @@ },

# Gulp-TypeDoc
[![NPM version](https://badge.fury.io/js/gulp-typedoc.svg)](http://badge.fury.io/js/gulp-typedoc)
[![NPM](https://nodei.co/npm/gulp-typedoc.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/gulp-typedoc/)
[![NPM](https://nodei.co/npm-dl/gulp-typedoc.png?months=9&height=3)](https://nodei.co/npm/gulp-typedoc/)
## Synopsis
Gulp plugin to execute the TypeDoc tool by Sebastian Lenz

@@ -29,2 +23,4 @@ http://typedoc.org

By default, the plugin will output log messages from TypeDoc. Specify `logger: 'none'` to suppress TypeDoc logging altogether.
## Code Example

@@ -61,2 +57,6 @@

### 2.1.0
* Add support for `logger` option.
### 2.0.3

@@ -113,2 +113,3 @@

* Pascal Berger
* Pedro Batista

@@ -115,0 +116,0 @@ ## License

@@ -1,18 +0,151 @@

#!node
// Copyright (c) 2015 Rogier Schouten <github@workingcode.ninja>
// License: ISC
var assert = require("assert");
var child_process = require("child_process");
var fs = require("fs");
var path = require("path");
"use strict";
var winExt = /^win/.test(process.platform)?".cmd":"";
var executable = path.join(__dirname, "..", "node_modules", ".bin", "gulp" + winExt);
var args = ["--gulpfile", path.join(__dirname, "gulpfile.js")];
const chai = require("chai");
const expect = chai.expect;
const child_process = require("child_process");
const fse = require("fs-extra");
const path = require("path");
const rimraf = require("rimraf");
const util = require("util");
child = child_process.spawn(path.resolve(executable), args, {
stdio: "inherit",
env: process.env
}).on("exit", function(code) {
assert(code == 0, "gulp returned nonzero exit code");
assert(fs.existsSync(path.join(__dirname, "out", "index.html")), "output documentation does not exist");
const primraf = util.promisify(rimraf);
const WIN_EXT = /^win/.test(process.platform)?".cmd" : "";
const GULP_PATH = path.resolve(path.join(__dirname, "..", "node_modules", ".bin", "gulp" + WIN_EXT));
const DATA_DIR = path.join(__dirname, "data");
const TEST_DIR = path.join(__dirname, "test");
/**
* Run gulp against TEST_DIR/gulpfile.js
* @returns {stderr, stdout}
*/
function run() {
return new Promise((resolve, reject) => {
const child = child_process.spawn(path.resolve(GULP_PATH), ["--gulpfile", "gulpfile.js"], {
env: process.env,
cwd: TEST_DIR
});
let stdout = "";
let stderr = "";
child.stdout.on("data", (data) => {
// console.log(data.toString());
stdout += data;
});
child.stderr.on("data", (data) => {
// console.error(data.toString());
stderr += data;
});
child.on("exit", (code) => {
if (code !== 0) {
reject(new Error(util.format("non-zero exit code %d; stdout: %s, stderr: %s", code, stdout, stderr)));
} else {
resolve({ stdout, stderr });
}
});
});
}
function gulpfile(typedocOpts) {
return `
const gulp = require("gulp");
const gulpTypeDoc = require("${path.relative(TEST_DIR, path.join(__dirname, "..", "index.js")).replace(/\\/g, "/")}");
// Workaround: directly calling process.exit() has corner cases where
// the console.log statements are not flushed (namely if stdout is piped
// instead of goes to a terminal).
const exitCode = 0;
process.on("exit", function() {
if (exitCode != 0) process.exit(exitCode);
});
// Generic error handling function
// This is needed because Gulp always returns exit code 0
// unless an exception is thrown which gives a useless stack trace.
function trapError(e) {
if (e.plugin && e.message) {
// it is a gulp plugin error
console.log("Error in plugin: " + e.plugin);
console.log(e.message);
}
else {
// some other error
gutil.log(e);
}
exitCode++;
}
gulp.task("default", () => {
return gulp
.src(["src/*.ts"])
.pipe(gulpTypeDoc(${JSON.stringify(typedocOpts)}))
.on("error", trapError) // make exit code non-zero
;
});
`;
}
describe("gulp-typedoc", function() {
this.timeout(60E3);
beforeEach(async () => {
await primraf(TEST_DIR);
await fse.mkdir(TEST_DIR);
await fse.mkdir(path.join(TEST_DIR, "src"));
await fse.copy(path.join(DATA_DIR, "myutil.ts"), path.join(TEST_DIR, "src", "myutil.ts"))
});
afterEach(async () => {
await primraf(TEST_DIR);
});
it("should create a .html file", async () => {
const g = gulpfile({
version: true,
module: "commonjs",
out: "./out",
json: "./out/test.json",
name: "gulp-typedoc-test",
target: "es5",
includeDeclarations: true
});
await fse.writeFile(path.join(TEST_DIR, "gulpfile.js"), g);
await run();
const exists = await fse.exists(path.join(TEST_DIR, "out", "index.html"));
expect(exists).to.equal(true);
});
it("should enable typedoc logging when nothing specified", async () => {
const g = gulpfile({
version: true,
module: "commonjs",
out: "./out",
json: "./out/test.json",
name: "gulp-typedoc-test",
target: "es5",
includeDeclarations: true
});
await fse.writeFile(path.join(TEST_DIR, "gulpfile.js"), g);
const {stdout, stderr} = await run();
expect(stdout).to.contain("Using TypeScript");
});
it("should disable typedoc logging when logger 'none' specified", async () => {
const g = gulpfile({
version: true,
module: "commonjs",
out: "./out",
json: "./out/test.json",
name: "gulp-typedoc-test",
target: "es5",
logger: "none",
includeDeclarations: true
});
await fse.writeFile(path.join(TEST_DIR, "gulpfile.js"), g);
const {stdout, stderr} = await run();
expect(stdout).to.not.contain("Using TypeScript");
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc