-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from tlivings/master
Fixes to tests generator, documentation.
- Loading branch information
Showing
10 changed files
with
139 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
var swaggerize = require('swaggerize-express/bin/lib/swaggerize'); | ||
var minimist = require('minimist'), | ||
swaggerize = require('./lib/swaggerize'), | ||
spawn = require('child_process').spawn; | ||
|
||
var result = swaggerize(process.argv); | ||
var swaggerize, result, args, npm; | ||
|
||
args = minimist(process.argv.slice(2)); | ||
|
||
result = swaggerize(args); | ||
|
||
if (result === 0 && args.tests) { | ||
npm = spawn('npm', ['install', '--save-dev', 'tape', 'body-parser', 'supertest']); | ||
|
||
npm.stdout.pipe(process.stdout); | ||
npm.stderr.pipe(process.stdout); | ||
|
||
npm.on('close', function (code) { | ||
process.exit(code); | ||
}); | ||
|
||
return; | ||
} | ||
|
||
process.exit(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,4 @@ | |
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "testpkg", | ||
"version": "0.0.0", | ||
"description": "test package.json", | ||
"devDependencies": { | ||
"body-parser": "^1.7.0", | ||
"tape": "^2.14.0", | ||
"supertest": "^0.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
var test = require('tape'), | ||
execFile = require('child_process').execFile, | ||
fs = require('fs'), | ||
path = require('path'), | ||
mkdirp = require('mkdirp'); | ||
|
||
test('swaggerize command', function (t) { | ||
var cwd = process.cwd(); | ||
|
||
mkdirp.sync(path.resolve('test/temp')); | ||
|
||
process.chdir(path.resolve('test/fixtures')); | ||
|
||
t.on('end', function () { | ||
process.chdir(cwd); | ||
|
||
function rm(dir) { | ||
var files = fs.readdirSync(dir); | ||
|
||
files && files.forEach(function (file) { | ||
var info = fs.statSync(file = path.join(dir, file)); | ||
|
||
info.isFile() && fs.unlinkSync(file); | ||
info.isDirectory() && rm(file); | ||
}); | ||
|
||
fs.rmdirSync(dir); | ||
} | ||
|
||
rm(path.resolve('test/temp')); | ||
}); | ||
|
||
t.test('npm devDependencies', function (t) { | ||
t.plan(5); | ||
|
||
execFile('../../bin/swaggerize.js', ['--api', 'api.json', '--handlers', '../temp/handlers', '--models', '../temp/models', '--tests', '../temp/tests'], function (error, stdout, stderr) { | ||
var pkg; | ||
|
||
stdout && console.log(stdout.toString()); | ||
stderr && console.log(stderr.toString()); | ||
error && console.error(error); | ||
|
||
t.ok(!error, 'no error.'); | ||
|
||
pkg = require(path.join(__dirname, 'fixtures/package.json')); | ||
|
||
t.ok(pkg.devDependencies, 'devDependencies exists.'); | ||
t.ok(pkg.devDependencies.tape, 'tape exists.'); | ||
t.ok(pkg.devDependencies['body-parser'], 'body-parser exists.'); | ||
t.ok(pkg.devDependencies.supertest, 'supertest exists.'); | ||
}); | ||
}); | ||
|
||
}); |