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

install-changed

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

install-changed - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

lib/main.js

39

index.js

@@ -1,38 +0,1 @@

var fs = require('fs')
var crypto = require('crypto')
// hashes a given file and returns the hex digest
const hashFile = (filepath) => {
var hashSum = crypto.createHash('md5')
var contents = fs.readFileSync(filepath)
hashSum.update(contents)
return hashSum.digest('hex')
}
// returns whether or not npm install should be executed
const watchFile = function () {
let packagePath = __dirname + '/../../package.json'
let packageHashPath = __dirname + '/../../packagehash.txt'
let recentDigest = hashFile(packagePath)
// if the hash file doesn't exist or if it does and the hash
// is different
if (!fs.existsSync(packageHashPath) || fs.readFileSync(packageHashPath, 'utf-8') !== recentDigest) {
fs.writeFileSync(packageHashPath, recentDigest) // write to hash to file for future use
console.log('will npm install')
return true
}
console.log('will not npm install')
return false
}
exports.printMsg = function () {
console.log("This is a message from the demo package");
}
watchFile()
require('./lib/main.js')()
{
"name": "install-changed",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -9,2 +9,5 @@ "main": "index.js",

},
"bin": {
"install-changed": "./bin/install-changed.js"
},
"keywords": [],

@@ -11,0 +14,0 @@ "author": "Youssef Swailem <youssefswailem@gmail.com>(http://github.com/ninesalt)",

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