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

csv-config

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-config - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

.editorconfig

141

csv-config.js

@@ -1,2 +0,1 @@

const path = require('path');

@@ -15,59 +14,83 @@ const fs = require('fs-extra');

function CsvConfig(name,islocal){
function CsvConfig(name, islocal) {
if(globalSymbols.indexOf(OBJ_KEY) < 0){
global[OBJ_KEY] = CONFIG;
}
else{
CONFIG = global[OBJ_KEY];
return CONFIG;
}
if (globalSymbols.indexOf(OBJ_KEY) < 0) {
global[OBJ_KEY] = CONFIG;
} else {
CONFIG = global[OBJ_KEY];
return CONFIG;
}
if(typeof name == "undefined") name = "csv-config";
if(typeof islocal == "undefined") islocal = false;
if (typeof name == "undefined") name = "csv-config";
if (typeof islocal == "undefined") islocal = false;
let cfgPathLocal = path.resolve(process.cwd(), name);;
let cfgPathHome = path.resolve(userHome, name);
if(islocal){
CONFIG['current-config-dir'] = cfgPathLocal;
}
else{
CONFIG['current-config-dir'] = cfgPathHome;
let cfgPathLocal = path.resolve(process.cwd(), name);;
let cfgPathHome = path.resolve(userHome, name);
if( ! fs.pathExistsSync(cfgPathHome)){
fs.mkdirsSync(cfgPathHome);
if(fs.pathExistsSync(cfgPathLocal)){
fs.copySync(cfgPathLocal,cfgPathHome,{overwrite:true});
}
}
}
if (islocal) {
CONFIG['current-config-dir'] = cfgPathLocal;
} else {
CONFIG['current-config-dir'] = cfgPathHome;
let parse_config = {delimiter:";",skipEmptyLines:true};
let unparse_config = {quotes: false,quoteChar: '"',delimiter:";",header:false,newline: "\r\n"};
if (!fs.pathExistsSync(cfgPathHome)) {
fs.mkdirsSync(cfgPathHome);
if (fs.pathExistsSync(cfgPathLocal)) {
fs.copySync(cfgPathLocal, cfgPathHome, {
overwrite: true
});
}
}
}
var files = fs.readdirSync( CONFIG['current-config-dir']);
let parse_config = {
delimiter: ";",
skipEmptyLines: true,
header: false
};
for(var i in files) {
let ext_name = path.extname(files[i]);
if( ext_name === ".csv") {
let base_name = path.basename(files[i],ext_name);
let file_path = path.resolve(CONFIG['current-config-dir'],files[i]);
let file_text = fs.readFileSync(file_path,'utf8');
CONFIG[base_name] = papa.parse(file_text,parse_config);
}
}
CONFIG['save'] = function (){
for (const [key, value] of Object.entries(CONFIG))
{
if(typeof(value) !== 'function' && key != 'current-config-dir')
{
let text = papa.unparse(CONFIG[key].data,unparse_config);
let file_path = path.resolve( CONFIG['current-config-dir'] ,`${key}.csv`);
fs.writeFileSync(file_path,text,'utf8');
}
}
};
return CONFIG;
let unparse_config = {
quotes: false,
quoteChar: '"',
delimiter: ";",
header: false,
newline: "\r\n",
header: false
};
var files = fs.readdirSync(CONFIG['current-config-dir']);
for (var i in files) {
let ext_name = path.extname(files[i]);
if (ext_name === ".csv") {
let base_name = path.basename(files[i], ext_name);
let file_path = path.resolve(CONFIG['current-config-dir'], files[i]);
let file_text = fs.readFileSync(file_path, 'utf8');
if (/^((#[^;\n\r]+)[;]?)+/.test(file_text)) {
debugger;
parse_config.header = true;
} else {
debugger;
parse_config.header = false;
}
CONFIG[base_name] = papa.parse(file_text, parse_config);
CONFIG[base_name].header = parse_config.header;
}
}
CONFIG['save'] = function () {
for (const [key, value] of Object.entries(CONFIG)) {
if (typeof (value) !== 'function' && key != 'current-config-dir') {
unparse_config.header = CONFIG[key].header;
let text = papa.unparse(CONFIG[key].data, unparse_config);
let file_path = path.resolve(CONFIG['current-config-dir'], `${key}.csv`);
fs.writeFileSync(file_path, text, 'utf8');
}
}
};
return CONFIG;
};

@@ -78,11 +101,9 @@

//for testing purpose
if (!module.parent)
{
let config = CsvConfig("CsvConfig",true);
config['atwords'].data[0][1] ++;
config['dotwords'].data[0][1] ++;
config['blacklist'].data[0][1] ++;
config.save();
if (!module.parent) {
let config = CsvConfig("CsvConfig", true);
debugger;
//config['atwords'].data[0][1]++;
//config['dotwords'].data[0][1]++;
//config['blacklist'].data[0][1]++;
//config.save();
}
{
"name": "csv-config",
"version": "1.1.4",
"description": "A `CSV` config parser and serializer for node.",
"main": "csv-config.js",
"keywords": [
"csv-config",
"config",
"csv",
"parser",
"serializer",
"ini",
"conf",
"configuration",
"configstore",
"cosmiconfig",
"cfg",
"winston-cfg",
"parse-config-file"
],
"dependencies": {
"path": "^0.12.7",
"fs-extra": "^4.0.3",
"user-home": "^2.0.0",
"papaparse": "^4.3.6"
},
"devDependencies": {
"mocha": "^4.0.1",
"path": "^0.12.7"
},
"scripts": {
"start": "node csv-config.js",
"test": "mocha --recursive"
},
"bugs": {
"url": "https://gitlab.com/autokent/csv-config/issues",
"email": "mehmet.kozan@live.com"
},
"homepage": "https://gitlab.com/autokent/csv-config",
"repository": {
"type": "git",
"url": "https://gitlab.com/autokent/csv-config.git"
},
"author": "Mehmet Kozan <mehmet.kozan@live.com>",
"license": "MIT",
"engines": {
"node": ">=6.8.1"
}
"name": "csv-config",
"version": "1.1.5",
"description": "A `CSV` config parser and serializer for node.",
"main": "csv-config.js",
"keywords": [
"csv-config",
"config",
"csv",
"parser",
"serializer",
"ini",
"conf",
"configuration",
"configstore",
"cosmiconfig",
"cfg",
"winston-cfg",
"parse-config-file"
],
"dependencies": {
"path": "^0.12.7",
"fs-extra": "^4.0.3",
"user-home": "^2.0.0",
"papaparse": "^4.3.6"
},
"devDependencies": {
"mocha": "^4.0.1",
"path": "^0.12.7"
},
"scripts": {
"start": "node csv-config.js",
"test": "mocha --recursive"
},
"bugs": {
"url": "https://gitlab.com/autokent/csv-config/issues",
"email": "mehmet.kozan@live.com"
},
"homepage": "https://gitlab.com/autokent/csv-config",
"repository": {
"type": "git",
"url": "https://gitlab.com/autokent/csv-config.git"
},
"author": "Mehmet Kozan <mehmet.kozan@live.com>",
"license": "MIT",
"engines": {
"node": ">=6.8.1"
}
}
# csv-config
> **A `CSV` config parser and serializer for node**
**A `CSV` config parser and serializer for node**
![logo](https://assets.gitlab-static.net/uploads/-/system/project/avatar/4802299/csv-config.png)
[![version](https://img.shields.io/npm/v/csv-config.svg)](https://www.npmjs.org/package/csv-config)

@@ -8,0 +6,0 @@ [![downloads](https://img.shields.io/npm/dt/csv-config.svg)](https://www.npmjs.org/package/csv-config)

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