Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stackvalidator

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stackvalidator - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

34

index.js

@@ -23,8 +23,12 @@ 'use strict';

const templates = [];
let counter = 0;
klaw(rootPath)
.on('data', item => {
const ext = path.extname(item.path)
const ext = path.extname(item.path);
if (['.yml', '.json'].includes(ext)) {
const contents = fs.readFileSync(item.path).toString();
if ((/AWSTemplateFormatVersion/g).test(contents)){
counter = counter + 1;
if (counter > 1000) {
return reject(new Error(`Lots of json and yml files found, is '${rootPath}/*' really the path you want to validate?`))
} else if ((/AWSTemplateFormatVersion/g).test(contents)){
templates.push(item);

@@ -34,4 +38,4 @@ }

})
.on('error', (err, item) =>
reject(new Error({ error, item })))
.on('error', (error, item) =>
reject(error))
.on('end', () =>

@@ -67,10 +71,16 @@ resolve({ templates }));

async function validateTemplates(rootPath, delay) {
const { templates } = await readTemplates(rootPath);
const templatePaths = templates.map(template => template.path);
console.log(chalk.yellow(`Found ${templatePaths.length} template${templatePaths.length !== 1 ? 's' : ''}\r\n${rootPath}`));
console.log(chalk.yellow(templatePaths.join(',\n').replace(new RegExp(rootPath, 'g'), ' └ ')));
console.log(chalk.yellow('---------------------------'));
templatePaths.forEach(template =>
queue.add(() =>
validateTemplate(template, delay)));
try {
const { templates } = await readTemplates(rootPath);
const templatePaths = templates.map(template => template.path);
console.log(chalk.yellow(`Found ${templatePaths.length} template${templatePaths.length !== 1 ? 's' : ''}\r\n${rootPath}`));
console.log(chalk.yellow(templatePaths.join(',\n').replace(new RegExp(rootPath, 'g'), ' └ ')));
console.log(chalk.yellow('---------------------------'));
templatePaths.forEach(template =>
queue.add(() =>
validateTemplate(template, delay)));
} catch (exception) {
console.log(chalk.red(`[ERROR] ${exception.message}`));
process.exit(1);
}
}

@@ -77,0 +87,0 @@

@@ -6,3 +6,3 @@ {

},
"version": "0.1.1",
"version": "0.1.2",
"author": "Eetu Tuomala",

@@ -9,0 +9,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

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