Skip to content

Commit

Permalink
fix(package.json): remove package.json and add packageJSON to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Apr 22, 2017
1 parent 789b9a0 commit fd0c206
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/ESDoc.js
Expand Up @@ -96,6 +96,11 @@ export default class ESDoc {
results.push(this._generateForIndex(config));
}

// config.package
if (config.package) {
results.push(this._generateForPackageJSON(config));
}

// manual
if (config.manual) {
results.push(...this._generateForManual(config));
Expand All @@ -119,15 +124,6 @@ export default class ESDoc {
fs.outputFileSync(filePath, json);
}

// package.json
try {
const json = fs.readFileSync(config.package, {encoding: 'utf-8'});
const filePath = path.resolve(config.destination, 'package.json');
fs.outputFileSync(filePath, json, {encoding: 'utf8'});
} catch (e) {
// ignore
}

// publish
this._publish(config);

Expand Down Expand Up @@ -305,6 +301,28 @@ export default class ESDoc {
return tag;
}

static _generateForPackageJSON(config) {
let packageJSON = '';
let packagePath = '';
try {
packageJSON = fs.readFileSync(config.package, {encoding: 'utf-8'});
packagePath = path.resolve(config.package);
} catch (e) {
// ignore
}

const tag = {
kind: 'packageJSON',
content: packageJSON,
longname: packagePath,
name: path.basename(packagePath),
static: true,
access: 'public'
};

return tag;
}

static _generateForManual(config) {
const results = [];

Expand Down

0 comments on commit fd0c206

Please sign in to comment.