New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jlint

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jlint - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

66

cli.js
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var jlint = require('./');
var argv = process.argv.slice(2);
const jlint = require('./');
const meow = require('meow');
var symbols = require("log-symbols");
var cardinal = require('cardinal');
const symbols = require('log-symbols');
const cardinal = require('cardinal');
function help() {
console.log([
'',
' ' + pkg.description,
'',
' Example',
' jlint',
'',
' ✔'
].join('\n'));
}
const cli = meow(`
Usage
$ jlint
if (argv.indexOf('--help') !== -1) {
help();
return;
}
Options
-s, --silent Don't output json
if (argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
function outputJson (lint) {
if (argv.indexOf('--silent') === -1) {
if (lint.parsed) {
console.log(cardinal.highlight(lint.content, {json: true}));
} else {
console.log(lint.content);
}
Examples
$ jlint --silent
`, {
alias: {
s: 'silent'
}
}
});
jlint(function (lint) {
outputJson(lint);
jlint((error, json) => {
if (error) {
console.log(error.message);
console.log(symbols.error);
if (lint.parsed) {
console.log(symbols.success);
} else {
console.log(symbols.error, lint.exception);
return;
}
process.exit(0);
if (!cli.flags.silent) {
console.log(cardinal.highlight(JSON.stringify(json, null, 2), {json: true}));
}
console.log(symbols.success);
});
'use strict';
var copypaste = require("copy-paste");
var Promise = require('es6-promise').Promise;
const parseJson = require('parse-json');
const copypaste = require('copy-paste');
const cardinal = require('cardinal');
var lint = {
parsed: void 0,
content: void 0,
exception: void 0
};
let parse = (content, cb) => {
try {
let json = parseJson(content);
var parse = function (content) {
try {
lint.parsed = true;
lint.content = JSON.stringify(JSON.parse(content), null, 2);
} catch(ex) {
lint.content = content;
lint.parsed = false;
lint.exception = ex;
cb(null, json);
} catch (e) {
cb(e);
}
return lint;
};
var promise;
let promise = new Promise((resolve, reject) => {
if (process.stdin && !process.stdin.isTTY) {
var data = '';
if (process.stdin && !process.stdin.isTTY) {
promise = new Promise(function (resolve) {
var stdinData = '';
process.stdin.on('data', (chunk) => {
chunk = chunk.toString();
process.stdin.on('data', function(data) {
var chunk = data.toString();
if (chunk !== null) {
stdinData += chunk;
data += chunk;
}
});
process.stdin.on('end', function () {
resolve(stdinData);
process.stdin.on('error', (err) => {
reject(err);
});
})
}
module.exports = function(callback){
if (process.stdin && !process.stdin.isTTY) {
promise.then(function (stdinData) {
callback(parse(stdinData));
process.stdin.on('end', () => {
resolve(data);
});
return;
}
});
copypaste.paste(function (err, content) {
if (err) {
console.log(err);
module.exports = (callback) => {
if (process.stdin && !process.stdin.isTTY) {
promise.then((content) => parse(content, callback)).catch(err => callback(err));
} else {
copypaste.paste((err, content) => {
if (err) {
throw err;
}
lint.parsed = false;
callback(lint);
}
var parsed = parse(content);
callback(lint, parsed);
});
parse(content, callback);
});
}
};
{
"name": "jlint",
"version": "1.1.1",
"description": "CLI that parses the current JSON you have in your current clipboard",
"version": "1.1.2",
"description": "cli that parses the current JSON you have in your current clipboard",
"main": "index.js",

@@ -42,5 +42,6 @@ "scripts": {

"cardinal": "0.5.0",
"copy-paste": "1.1.2",
"es6-promise": "2.3.0",
"log-symbols": "1.0.2"
"copy-paste": "1.1.3",
"log-symbols": "1.0.2",
"meow": "3.4.2",
"parse-json": "2.2.0"
},

@@ -47,0 +48,0 @@ "devDependencies": {

@@ -1,10 +0,9 @@

# jlint [![Build Status](http://img.shields.io/travis/srn/jlint.svg?style=flat-square)](https://travis-ci.org/srn/jlint) [![Dependency Status](http://img.shields.io/gemnasium/srn/jlint.svg?style=flat-square)](https://gemnasium.com/srn/jlint)
# jlint [![Build Status](http://img.shields.io/travis/srn/jlint.svg?style=flat-square)](https://travis-ci.org/srn/jlint)
> cli that parses the JSON you have in your current clipboard
> CLI that parses the current JSON you have in your current clipboard.
## Install
```sh
$ npm install --global jlint
$ npm i -g jlint
```

@@ -20,3 +19,2 @@

✔︎
{

@@ -26,5 +24,6 @@ "hello": 1,

}
✔︎
```
Piping:
Piping also works:

@@ -31,0 +30,0 @@ ```sh

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