Socket
Socket
Sign inDemoInstall

google-it

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-it - npm Package Compare versions

Comparing version 1.5.4 to 1.6.0

8

lib/googleIt.js

@@ -173,3 +173,5 @@ "use strict";

userAgent = _ref2.userAgent,
start = _ref2.start;
start = _ref2.start,
includeSites = _ref2.includeSites,
excludeSites = _ref2.excludeSites;
// eslint-disable-next-line consistent-return

@@ -197,3 +199,5 @@ return new Promise(function (resolve, reject) {

userAgent: userAgent,
start: start
start: start,
includeSites: includeSites,
excludeSites: excludeSites
});

@@ -200,0 +204,0 @@ request(_objectSpread(_objectSpread({}, defaultOptions), options), function (error, response, body) {

@@ -56,7 +56,2 @@ "use strict";

type: Boolean
}, // option to limit results to only these two sites
{
name: 'stackoverflow-github-only',
alias: 'X',
type: Boolean
}, // option to open the first X number of results directly in browser

@@ -94,3 +89,13 @@ // (only tested on Mac!).

type: Boolean
}, // modifies the search query by adding "site:" operator for each comma-separated value,
// combined with OR operator when there are multiple values
{
name: 'includeSites',
type: String
}, // modifies the search query by adding "-site:" operator for each comma-separated value,
// combined with AND operator when there are multiple values
{
name: 'excludeSites',
type: String
}];
module.exports = optionDefinitions;

@@ -13,3 +13,7 @@ "use strict";

GOOGLE_IT_RESULT_STATS_SELECTOR = _process$env.GOOGLE_IT_RESULT_STATS_SELECTOR,
GOOGLE_IT_CURSOR_SELECTOR = _process$env.GOOGLE_IT_CURSOR_SELECTOR; // NOTE:
GOOGLE_IT_CURSOR_SELECTOR = _process$env.GOOGLE_IT_CURSOR_SELECTOR,
_process$env$GOOGLE_I = _process$env.GOOGLE_IT_INCLUDE_SITES,
GOOGLE_IT_INCLUDE_SITES = _process$env$GOOGLE_I === void 0 ? '' : _process$env$GOOGLE_I,
_process$env$GOOGLE_I2 = _process$env.GOOGLE_IT_EXCLUDE_SITES,
GOOGLE_IT_EXCLUDE_SITES = _process$env$GOOGLE_I2 === void 0 ? '' : _process$env$GOOGLE_I2; // NOTE:
// I chose the User-Agent value from http://www.browser-info.net/useragents

@@ -22,2 +26,24 @@ // Not setting one causes Google search to not display results

var getFullQuery = function getFullQuery(query) {
var includeSites = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GOOGLE_IT_INCLUDE_SITES;
var excludeSites = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : GOOGLE_IT_EXCLUDE_SITES;
if (includeSites === '' && excludeSites === '') {
return query;
}
if (includeSites !== '') {
var _addition = includeSites.split(',').map(function (site) {
return " site:".concat(site);
}).join(' OR');
return query + _addition;
}
var addition = excludeSites.split(',').map(function (site) {
return " -site:".concat(site);
}).join(' AND');
return query + addition;
};
var getDefaultRequestOptions = function getDefaultRequestOptions(_ref) {

@@ -27,7 +53,9 @@ var limit = _ref.limit,

userAgent = _ref.userAgent,
start = _ref.start;
start = _ref.start,
includeSites = _ref.includeSites,
excludeSites = _ref.excludeSites;
return {
url: 'https://www.google.com/search',
qs: {
q: query,
q: getFullQuery(query, includeSites, excludeSites),
num: limit || defaultLimit,

@@ -108,3 +136,4 @@ start: start || defaultStart

saveToFile: saveToFile,
saveResponse: saveResponse
saveResponse: saveResponse,
getFullQuery: getFullQuery
};
{
"name": "google-it",
"version": "1.5.4",
"version": "1.6.0",
"description": "A CLI and Node.js library to help retrieve, display, and store Google search results",

@@ -5,0 +5,0 @@ "main": "./lib/main.js",

@@ -39,3 +39,4 @@ # google-it [![Build Status](https://travis-ci.org/PatNeedham/google-it.svg?branch=master)](https://travis-ci.org/PatNeedham/google-it) [![npm version](https://badge.fury.io/js/google-it.svg)](https://www.npmjs.com/package/google-it) [![Codecov Coverage](https://img.shields.io/codecov/c/github/PatNeedham/google-it/master.svg?style=flat-square)](https://codecov.io/gh/PatNeedham/google-it/) [![Maintainability](https://api.codeclimate.com/v1/badges/fe8329b7641ea86326e4/maintainability)](https://codeclimate.com/github/PatNeedham/google-it/maintainability)

- [ ] *bold-matching-text* - only takes effect when interactive (-i) flag is set as well, will bold test in results that matched the query
- [ ] *stackoverflow-github-only* - option to limit results to only these two sites
- [x] *includeSites* - option to limit results to comma-separated list of sites
- [x] *excludeSites* - option to exclude results that appear in comma-separated list of sites
- [x] *open* - opens the first X number of results in the browser after finishing query

@@ -42,0 +43,0 @@ - [x] *disableConsole* - intended to be used with programmatic use, so that the color-coded search results are not displayed in the terminal (via console.log) when not wanted.

@@ -137,2 +137,4 @@ /* eslint-disable no-console */

start,
includeSites,
excludeSites,
}) {

@@ -152,3 +154,3 @@ // eslint-disable-next-line consistent-return

const defaultOptions = getDefaultRequestOptions({
limit, query, userAgent, start,
limit, query, userAgent, start, includeSites, excludeSites,
});

@@ -155,0 +157,0 @@ request({ ...defaultOptions, ...options }, (error, response, body) => {

@@ -36,5 +36,2 @@ const optionDefinitions = [

// option to limit results to only these two sites
{ name: 'stackoverflow-github-only', alias: 'X', type: Boolean },
// option to open the first X number of results directly in browser

@@ -58,4 +55,12 @@ // (only tested on Mac!).

{ name: 'diagnostics', alias: 'd', type: Boolean },
// modifies the search query by adding "site:" operator for each comma-separated value,
// combined with OR operator when there are multiple values
{ name: 'includeSites', type: String },
// modifies the search query by adding "-site:" operator for each comma-separated value,
// combined with AND operator when there are multiple values
{ name: 'excludeSites', type: String },
];
module.exports = optionDefinitions;

@@ -12,2 +12,4 @@ /* eslint-disable no-extra-parens */

GOOGLE_IT_CURSOR_SELECTOR,
GOOGLE_IT_INCLUDE_SITES = '',
GOOGLE_IT_EXCLUDE_SITES = '',
} = process.env;

@@ -23,8 +25,24 @@

const getFullQuery = (
query,
includeSites = GOOGLE_IT_INCLUDE_SITES,
excludeSites = GOOGLE_IT_EXCLUDE_SITES
) => {
if (includeSites === '' && excludeSites === '') {
return query;
}
if (includeSites !== '') {
const addition = includeSites.split(',').map((site) => ` site:${site}`).join(' OR');
return query + addition;
}
const addition = excludeSites.split(',').map((site) => ` -site:${site}`).join(' AND');
return query + addition;
};
const getDefaultRequestOptions = ({
limit, query, userAgent, start,
limit, query, userAgent, start, includeSites, excludeSites,
}) => ({
url: 'https://www.google.com/search',
qs: {
q: query,
q: getFullQuery(query, includeSites, excludeSites),
num: limit || defaultLimit,

@@ -105,2 +123,3 @@ start: start || defaultStart,

saveResponse,
getFullQuery,
};
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc