Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es6 style #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions bin/swagger2js.js
@@ -1,12 +1,13 @@
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
var updateNotifier = require('update-notifier');
const path = require('path');
const fs = require('fs');
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');

//1. Update Notifier
var pkg = require('../package.json');
const lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');

// Update Notifier
updateNotifier({packageName: pkg.name, packageVersion: pkg.version}).notify();

//4. CLI Script
// CLI Script
require(lib + '/cli.js');
2 changes: 1 addition & 1 deletion circle.yml
@@ -1,6 +1,6 @@
machine:
node:
version: 5.7.0
version: 14.16.0
dependencies:
post:
- npm install grunt-cli -g
8 changes: 4 additions & 4 deletions lib/cli.js
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const pkg = require('../package.json');
const cli = require('commander');
const yaml = require('js-yaml').safeLoad;
const CodeGen = require('./codegen').CodeGen;
const CodeGen = require('./codegen.js').CodeGen;

cli
.version(pkg.version)
Expand All @@ -17,14 +17,14 @@ cli
.option('-l, --lint', 'Whether or not to run jslint on the generated code [false]')
.option('-b, --beautify', 'Whether or not to beautify the generated code [false]')
.action((file, imports, options) => {
const fnName = 'get' + options.type.charAt(0).toUpperCase() + options.type.substr(1) + 'Code';
const fnName = `get${options.type.charAt(0).toUpperCase()}${options.type.substr(1)}Code`;
const fn = CodeGen[fnName];
options.lint = options.lint || false;
options.beautify = options.beautify || false;

const content = fs.readFileSync(file, 'utf-8');

var swagger;
let swagger;
try {
swagger = JSON.parse(content);
} catch (e) {
Expand All @@ -34,7 +34,7 @@ cli
const result = fn({
moduleName: options.module,
className: options.class,
swagger: swagger,
swagger,
lint: options.lint,
beautify: options.beautify
});
Expand Down