Socket
Socket
Sign inDemoInstall

google-it

Package Overview
Dependencies
5
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.1.0

10

package.json
{
"name": "google-it",
"version": "1.0.5",
"description": "A command line utility to help retrieve, display, and store Google search results",
"main": "./app.js",
"version": "1.1.0",
"description": "A CLI and Node.js library to help retrieve, display, and store Google search results",
"main": "./googleIt.js",
"bin": "./app.js",

@@ -23,3 +23,3 @@ "repository": {

"colors": "^1.1.2",
"command-line-args": "^4.0.7",
"command-line-args": "^5.0.0",
"ora": "^1.3.0",

@@ -30,5 +30,5 @@ "request": "^2.81.0"

"eslint": "^4.8.0",
"mocha": "^3.5.3",
"mocha": "^5.0.0",
"prettier": "1.10.2"
}
}

@@ -1,2 +0,2 @@

# google-it ![Travis-CI](https://travis-ci.org/PatNeedham/google-it.svg?branch=master)
# google-it [![Build Status](https://travis-ci.org/PatNeedham/google-it.svg?branch=master)](https://travis-ci.org/PatNeedham/google-it) [![Greenkeeper badge](https://badges.greenkeeper.io/PatNeedham/google-it.svg)](https://greenkeeper.io/)

@@ -36,3 +36,3 @@ A simple library to convert Google search results to JSON output, with an interactive display option coming in the near future.

- [ ] something like:
- [x] something like:

@@ -39,0 +39,0 @@ ```js

var assert = require('assert')
var googleIt = require('../googleIt')
var validateCLIArguments = require('../validateCLIArguments')
var optionDefinitions = require('../optionDefinitions')

@@ -30,1 +32,16 @@ describe('Validate output file format', () => {

});
describe('Ensure programmatic access works', () => {
it('Should have results that exist', (done) => {
var options = {
"query": "Statue of liberty",
"no-display": true
}
googleIt(options).then(results => {
assert.notEqual(results, null, "Results must exist")
done()
}).catch(err => {
done(err)
})
})
})

@@ -1,29 +0,38 @@

function validateCLIArguments(args) {
const MISSING_QUERY = 'missing_query'
const OUTPUT_ARG_MUST_BE_STRING = 'output_arg_must_be_string'
const MUST_END_IN_JSON = 'must_end_in_json'
const ONLY_ONE_NOT_BOTH = 'only_one_not_both'
const VALID = 'valid'
function getError(reason) {
return { valid: false, Error: reason }
}
const validationMap = {
[MISSING_QUERY]: getError('Missing querry'),
[OUTPUT_ARG_MUST_BE_STRING]: getError('Output argument must be string'),
[MUST_END_IN_JSON]: getError('Output argument must end in .json'),
[ONLY_ONE_NOT_BOTH]: getError('Can only use --no-display when --output is used as well')
}
function getPotentialError(args) {
var error = null
if (!args['query']) {
return {
valid: false,
'Error': 'Missing query'
}
error = MISSING_QUERY
} else if (args['output'] && typeof args['output'] !== 'string') {
return {
valid: false,
'Error': 'output argument must be string'
}
error = OUTPUT_ARG_MUST_BE_STRING
} else if (args['output'] && !args['output'].endsWith('.json')) {
return {
valid: false,
'Error': 'output argument must end in .json'
}
error = MUST_END_IN_JSON
} else if (args['no-display'] && !args['output']) {
return {
valid: false,
'Error': 'can only use --no-display when --output is used as well'
}
} else {
return {
valid: true
}
error = ONLY_ONE_NOT_BOTH
}
return validationMap[error]
}
function validateCLIArguments(args) {
var result = { valid: true }
var error = getPotentialError(args)
return error ? error : result
}
module.exports = validateCLIArguments

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc