Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .jshintrc

This file was deleted.

1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.jshintrc
.editorconfig
test
27 changes: 14 additions & 13 deletions bin/httpsnippet
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

'use strict'

var chalk = require('chalk')
var cmd = require('commander')
var fs = require('fs')
var readFile = require('fs-readfile-promise')
var writeFile = require('fs-writefile-promise')
var HTTPSnippet = require('..')
var path = require('path')
var pkg = require('../package.json')
const chalk = require('chalk')
const cmd = require('commander')
const fs = require('fs')
const readFile = require('fs-readfile-promise')
const writeFile = require('fs-writefile-promise')
const HTTPSnippet = require('..')
const path = require('path')
const pkg = require('../package.json')

cmd
.version(pkg.version)
Expand All @@ -23,16 +23,17 @@ if (!cmd.args.length || !cmd.target) {
cmd.help()
}

let dir
if (cmd.output) {
var dir = path.resolve(cmd.output)
dir = path.resolve(cmd.output)

if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}
}

cmd.args.forEach(function (fileName) {
var file = path.basename(fileName)
const file = path.basename(fileName)

readFile(fileName)
.then(JSON.parse)
Expand All @@ -57,7 +58,7 @@ cmd.args.forEach(function (fileName) {

.then(function (output) {
if (!output) {
var targetNames = HTTPSnippet.availableTargets().map(function (t) { return t.key }).join(', ')
const targetNames = HTTPSnippet.availableTargets().map(function (t) { return t.key }).join(', ')
return console.error('%s %s is not a valid target. Valid targets: %s', chalk.red('✖'), chalk.red(cmd.target), chalk.cyan(targetNames))
}

Expand All @@ -67,9 +68,9 @@ cmd.args.forEach(function (fileName) {
}

// write to file
var name = path.basename(file, path.extname(file))
const name = path.basename(file, path.extname(file))

var filename = path.format({
const filename = path.format({
dir: dir,
base: name + HTTPSnippet.extname(cmd.target)
})
Expand Down
Loading