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

codin

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codin - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

21

index.js

@@ -5,4 +5,2 @@ #!/usr/bin/env node

const { resolve } = require('path');
const parseArgs = require('minimist');

@@ -33,6 +31,3 @@ const chalk = require('chalk');

if (tests.length === 0) {
// eslint-disable-next-line global-require
global.readline = require('./readline');
// eslint-disable-next-line global-require
require(resolve(file));
run(file);
} else {

@@ -42,7 +37,8 @@ let n = 0;

n++;
const output = run(input.join('\n'), file).trim();
if (output !== expected.join('\n')) {
const [ output, error ] = run(file, input.join('\n'));
const troutput = output.trim();
if (troutput !== expected.join('\n')) {
console.error(
// eslint-disable-next-line indent
`${chalk.red(`Test #${n} failed`)}
`${chalk.red(`${file}: Test #${n} failed`)}
Input:

@@ -53,3 +49,6 @@ ${input.join('\n ')}

Actual output:
${output.split('\n').join('\n ')}`);
${troutput.split('\n').join('\n ') +
(error
? '\n Error output:\n ' + error.split('\n').join('\n ')
: '')}`);
}

@@ -62,3 +61,1 @@ }

readTests().then(main);
// require(resolve(process.argv[2]));
{
"name": "codin",
"version": "0.0.2",
"version": "0.0.3",
"description": "CodinGame CLI wrapper for Node.js (probably more languages later)",

@@ -5,0 +5,0 @@ "main": "index.js",

'use strict';
const { join } = require('path');
const { platform } = require('os');
const { join, extname } = require('path');
const { spawnSync } = require('child_process');
const run = (input, path) => {
const { stdout } = spawnSync(
'node',
[
'-r', join(__dirname, 'setup.js'),
path
],
{ input });
return String(stdout);
const runners = {
js: (path, input) => {
const { stdout, stderr } = spawnSync(
'node',
[
'-r', join(__dirname, 'setup.js'),
path
],
input
? { input }
: { stdio: 'inherit' });
return [ String(stdout), String(stderr) ];
},
ts: (path, input) => {
const { stdout, stderr } = spawnSync(
platform() === 'win32'
? 'cmd'
: 'ts-node',
[
...platform() === 'win32'
? [ '/c', 'ts-node' ]
: [],
'-r', join(__dirname, 'setup.js'),
path
],
input
? { input }
: { stdio: 'inherit' });
return [ String(stdout), String(stderr) ];
}
};
const run = (path, input = null) => {
const type = extname(path).slice(1);
if (type in runners) {
return runners[type](path, input);
}
throw new TypeError('Unknown file type: ' + type);
};
module.exports = run;
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