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

ohm-builder

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

ohm-builder - npm Package Compare versions

Comparing version 0.3.1 to 0.3.3

48

ohm-builder.js

@@ -22,23 +22,33 @@ #!/usr/bin/env node

// Replace all ohm tags with inlining the code
var regexString = '<script src=".*.ohm" type="text/ohm-js"></script>';
var matchString = grep(regexString, inputFile).trim();
if (!matchString) { // try the other order
regexString = '<script type="text/ohm-js" src=".*.ohm"></script>';
matchString = grep(regexString, inputFile).trim();
var regex = /<script\s+type="text\/ohm-js"\s+src=".*\.ohm"><\/script>/;
var matchStrings = grep(regex, inputFile).trim().split('\n').map(function(x) {
return x.trim();
}).filter(function (x) {
if (x) return x;
});
if (!matchStrings.length) { // try the other order
regex = /<script\s+src=".*\.ohm"\s+type="text\/ohm-js"><\/script>/;
matchStrings = grep(regex, inputFile).split('\n').map(function(x) {
return x.trim();
});
}
if (!matchString) {
var output = cat(inputFile);
if (!matchStrings.length) {
console.error('Warn: could not find script tag');
var output = cat(inputFile);
} else {
var sourceDir = path.dirname(outputFile || inputFile);
var ohmFile = path.join(sourceDir, matchString.match(/src="(.*)"/)[1]);
var ohmGrammar = cat(ohmFile).trim();
var newTag = matchString
.replace('></script>', '>\n' + ohmGrammar + '\n</script>')
.replace(/\s+src=".*"/, '');
var output = sed(matchString.trim(), newTag.trim(), inputFile);
if (output.trim() === cat(inputFile).trim()) {
echo('No replacement was made. Internal error.');
exit(4);
}
matchStrings.forEach(function (matchString) {
if (!matchString)
return;
var sourceDir = path.dirname(outputFile || inputFile);
var ohmFile = path.join(sourceDir, matchString.match(/src="([^"]+)"/)[1]);
var ohmGrammar = cat(ohmFile).trim();
var newTag = matchString
.replace(/\s+src="[^"]*"/, '')
.replace('></script>', '>\n' + ohmGrammar + '\n</script>');
output = output.replace(matchString.trim(), newTag.trim());
if (output.trim() === cat(inputFile).trim()) {
echo('No replacement was made. Internal error.');
exit(4);
}
});
}

@@ -51,2 +61,2 @@

console.error('Success!');
console.warn('Success!');
{
"name": "ohm-builder",
"version": "0.3.1",
"version": "0.3.3",
"description": "Bring ohm to your browser the easy way",

@@ -5,0 +5,0 @@ "main": "ohm-builder.js",

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