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

stayte

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stayte - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

4

package.json
{
"name": "stayte",
"version": "0.0.2",
"version": "0.0.3",
"description": "The persistent state library for the modern web",

@@ -18,3 +18,3 @@ "exports": {

"scripts": {
"postinstall": "node scripts/patch.js",
"postinstall": "node scripts/patch.js > file",
"dev": "rollup --config rollup.config.mjs --watch",

@@ -21,0 +21,0 @@ "build": "rm -rf dist && rollup --config rollup.config.mjs"

const fs = require('fs')
const path = require('path')

@@ -25,2 +26,4 @@ const init_cwd = process.env.INIT_CWD

const scannedPackages = getScannedPackages()
// Loop over the patch object and check if the package is already patched

@@ -31,2 +34,9 @@ // if not, we apply the patch in the current directory where statye will be installed

// If the package is not installed on every project, we skip it
const packageName = name.split('@')[0]
if (!scannedPackages.find((packageJson) => packageJson.dependencies[packageName])) {
continue
}
if (!packageJson.patchedDependencies[name]) {

@@ -44,2 +54,39 @@ const patchPath = `${cwd}/${patch}`

fs.writeFileSync(`${init_cwd}/package.json`, JSON.stringify(packageJson, null, 2), 'utf-8')
fs.writeFileSync(`${init_cwd}/package.json`, JSON.stringify(packageJson, null, 2), 'utf-8')
function getScannedPackages() {
const packages = searchFiles(init_cwd, 'package.json')
return packages.map((packageJson) => {
const packageJsonContent = fs.readFileSync(packageJson, 'utf-8')
const packageJsonObject = JSON.parse(packageJsonContent)
return packageJsonObject
})
}
function searchFiles(dir, fileName) {
let foundedFiles = []
try {
// read the contents of the directory
const files = fs.readdirSync(dir)
// search through the files
for (const file of files) {
// build the full path of the file
const filePath = path.join(dir, file);
// get the file stats
const fileStat = fs.statSync(filePath);
// if the file is a directory, recursively search the directory
if (fileStat.isDirectory() && !file.match(/node_modules|.git|.turbo|\./)) {
foundedFiles.push(...searchFiles(filePath, fileName))
} else if (file.endsWith(fileName)) {
foundedFiles.push(filePath);
}
}
} catch (err) {
console.error(err);
}
return foundedFiles;
}
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