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

eol-converter-cli

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eol-converter-cli - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

examples/README.md

4

package.json
{
"name": "eol-converter-cli",
"version": "1.0.5",
"version": "1.0.6",
"description": "Newline converter CLI for simple CRLF -> LF (and reverse) convertions of multiple files.",

@@ -10,3 +10,3 @@ "main": "src/index.js",

"scripts": {
"eolConverter": "node src/index.js"
"start": "node src/index.js"
},

@@ -13,0 +13,0 @@ "keywords": [

@@ -5,8 +5,8 @@ #!/usr/bin/env node

const eol = require('eol')
const glob = require("glob")
const glob = require('glob')
const fs = require('fs')
const path = require('path')
const argv = process.argv;
const inputFiles = argv[argv.length - 1]
const argv = process.argv
const inputFilesGlob = argv[argv.length - 1]
const isWarmup = argv[argv.length - 2] === 'warmup'

@@ -16,8 +16,11 @@ const isCrlf = argv[argv.length - 2] === 'crlf'

const dir = process.cwd()
console.log('Running in directory ' + dir)
console.log('Files GLOB regex: ' + inputFiles)
console.log(isWarmup ? 'WARMUP: will only list files, no action will be performed - run `convertToLF` to do conversion' : '')
console.log('Files GLOB regex: ' + inputFilesGlob)
console.log(isWarmup
? 'WARMUP: will only list files, no action will be performed'
: 'Converting to ' + (isCrlf ? 'CRLF' : 'LF'))
console.log('---')
glob(inputFiles, null, function (er, files) {
glob(inputFilesGlob, null, function (er, files) {
if (!files || files.length === 0) {

@@ -28,13 +31,14 @@ return console.error('ERROR: no files found')

console.log(fileName)
if (!isWarmup) {
try {
const file = fs.readFileSync(path.join(dir, fileName))
const converted = isCrlf ? eol.crlf(file.toString()) : eol.lf(file.toString())
fs.writeFileSync(fileName, converted);
} catch (error) {
console.warn(error)
}
if (isWarmup) {
return;
}
try {
const fileContent = fs.readFileSync(path.join(dir, fileName)).toString()
const convertFn = (isCrlf ? eol.crlf : eol.lf).bind(eol)
fs.writeFileSync(fileName, convertFn(fileContent))
} catch (error) {
console.warn(error)
}
})
console.log('---')
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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