install-changed
Advanced tools
Comparing version 1.0.2 to 1.0.3
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)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1403
4
25