Skip to content

Commit

Permalink
Fixed yarn global usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Sturgeon committed Feb 15, 2018
1 parent a63820d commit bdba0a8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.3.1] - 2018-02-15
### Added
- Fixed `serve` command when package is installed via yarn global

## [0.3.0] - 2018-02-15
### Added
- New `serve` command, to serve up ReDoc documentation without needing a local html file and your own server
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "speccy",
"version": "0.3.0",
"version": "0.3.1-6",
"description": "Your friendly OpenAPI v3.0 #WellActually CLI assistant.",
"bin": {
"speccy": "./speccy.js"
},
"scripts": {
"test": "mocha"
},
"preferGlobal": true,
"browserify": {
"transform": [
[
Expand All @@ -24,12 +25,11 @@
"url": "https://github.com/wework/speccy.git",
"type": "git"
},
"author": "Mike Ralphson <mike.ralphson@gmail.com>",
"author": "Phil Sturgeon <phil.sturgeon@wework.com>",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/wework/speccy/issues"
},
"bundleDependencies": false,
"dependencies": {
"ajv": "^5.0.1",
"browser-sync": "^2.17.0",
Expand All @@ -49,8 +49,7 @@
"openapi",
"openapi2",
"openapi3",
"converter",
"conversion",
"documentation",
"validator",
"validation",
"resolver",
Expand Down
11 changes: 6 additions & 5 deletions serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const browserSync = require('browser-sync');
const ejs = require('ejs');
const express = require('express');
const path = require('path');
const fs = require('fs');
const yaml = require('js-yaml');

Expand All @@ -18,7 +19,8 @@ const command = (file, cmd) => {
const html = loadHTML(file);
const port = cmd.port;

app.use('/assets/redoc', express.static(__dirname + '/node_modules/redoc/bundles'))
const bundleDir = path.dirname(require.resolve('redoc'));
app.use('/assets/redoc', express.static(bundleDir));

app.get('/spec.json', function (req, res) {
const spec = loadSpec(file);
Expand Down Expand Up @@ -86,16 +88,15 @@ function loadSpec(path) {
}

function loadHTML(file) {
let html;
try {
const template = fs.readFileSync(__dirname + '/templates/index.html', 'utf8');
html = ejs.render(template, {spec: file});
const templateFile = path.resolve(__dirname, 'templates/index.html');
const template = fs.readFileSync(templateFile, 'utf8');
return ejs.render(template, { spec: file });
}
catch (e) {
console.error('failed to load html file: ' + e.message);
process.exit(1);
}
return html;
}

module.exports = { command }
10 changes: 0 additions & 10 deletions test/!missing-ref/openapi.yaml

This file was deleted.

1 change: 0 additions & 1 deletion test/!missing-ref/options.yaml

This file was deleted.

0 comments on commit bdba0a8

Please sign in to comment.