chttps
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,26 +0,30 @@ | ||
var fs = require("fs"); | ||
var fs = require('fs'); | ||
var packageFolder = process.argv[process.argv.length - 1]; // picking the last argument as the directory | ||
var path = packageFolder + "/package-lock.json"; | ||
var path = packageFolder + '/package-lock.json'; | ||
var stats = fs.lstatSync(path); | ||
var isFile = stats.isFile(); | ||
if (!isFile) { | ||
console.log("File not found:'"+ path + "'"); | ||
console.log('File not found:"'+ path + '"'); | ||
} else { | ||
console.log("Reading from:'" + path + "'"); | ||
var text = fs.readFileSync(path, "utf-8"); | ||
console.log('Reading from:"' + path + '"'); | ||
var text = fs.readFileSync(path, 'utf-8'); | ||
if (text.match("http://")) { | ||
var newText = ""; | ||
var lines = text.split("\n"); | ||
if (text.match('resolved": "http://')) { | ||
var newText = ''; | ||
var lines = text.split('\n'); | ||
var n = lines.length; | ||
for (var i = 0; i < n; i++) { | ||
newText += lines[i].replace("http://", "https://") + "\n"; | ||
newText += lines[i].replace( | ||
'resolved": "http://', | ||
'resolved": "https://' | ||
); | ||
if (i < n - 1) newText += '\n'; | ||
} | ||
console.log("Writing to:'" + path + "'"); | ||
console.log('Writing to:"' + path + '"'); | ||
fs.writeFileSync(path, newText); | ||
} else { | ||
console.log("OK. No 'http://' match."); | ||
console.log('OK. No ' + 'resolved": "http://' + ' match.'); | ||
} | ||
} |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Plotly, Inc.", | ||
@@ -8,0 +8,0 @@ "main": "chttps.js", |
@@ -1,12 +0,22 @@ | ||
# replace | ||
`chttps` is a command line utility for replacing http links on package-lock JSON files. It is inspired by and initially based on https://www.npmjs.com/package/replace. It has fewer config options and dependencies; while it is intented to only change the first occurance of http links with https on each line i.e. without regular expression. Caution: the input package-lock.json file must have line-breaks for each item and should be stored in utf-8 format. | ||
# chttps | ||
`chttps` is a minimal command line utility for replacing resolved http links on package-lock JSON files with https. | ||
Chttps (Change http to https) was inspired by and initially based on https://www.npmjs.com/package/replace code. It has fewer config options and no dependency; whereas it is intented to only change the very first occurance of http links with https on each line i.e. without regular expression. | ||
Caution: the input package-lock.json file must have line-breaks for each item and should be stored in utf-8 format. | ||
# Install | ||
npm install chttps --global | ||
npm install chttps --global | ||
You can now use `chttps` from the command line. | ||
OR: | ||
npm install chttps --save-dev | ||
Then add the following line to the script tag within the package.json file of the desired module. | ||
"scripts": { | ||
... | ||
"postshrinkwrap": "chttps ." | ||
} | ||
## Examples | ||
Replace all (i.e. first on every line) occurrences of "http://" with "https://" in the package-lock.json in the current directory: | ||
Replace all occurrences (i.e. the first ones on every line) of 'resolved": "http://' with 'resolved": "https://' in the package-lock.json in the current directory: | ||
@@ -17,3 +27,3 @@ ``` | ||
Replace all (i.e. first on every line) occurrences of "http://" with "https://" in the package-lock.json in another directory: | ||
Replace all occurrences (i.e. the first ones on every line) of 'resolved": "http://' with 'resolved": "https://' in the package-lock.json in another directory: | ||
@@ -20,0 +30,0 @@ ``` |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3698
27
32