From b477fb0a70ebb69fa71314d31dba16c28af48115 Mon Sep 17 00:00:00 2001 From: Christian Proske Date: Wed, 15 Oct 2025 10:28:11 +0200 Subject: [PATCH 1/4] updated dependencies --- bin/dot-object | 207 +++++++++++++++++++++++++------------------------ package.json | 4 +- 2 files changed, 108 insertions(+), 103 deletions(-) diff --git a/bin/dot-object b/bin/dot-object index 3211d5b..f6430f7 100755 --- a/bin/dot-object +++ b/bin/dot-object @@ -2,7 +2,7 @@ // vim: set filetype=javascript: 'use strict'; -var glob = require('glob'); +var {globSync, Glob} = require('glob'); var fs = require('fs'); /** @@ -11,123 +11,128 @@ var fs = require('fs'); * */ var dotob = require('../index.js'); -var program = require('commander'); +var {Command} = require('commander'); +var program = new Command(); var pkg = require('../package.json'); -program - .version(pkg.version) - .usage('[options]') - .option('-p, --pattern [pattern]', 'Files pattern to match or just the file') - .option('-f, --from [path,..]', 'From path') - .option('-t, --to [path,..]', 'To path (number of replacements must match --to values)') - .option('-m, --merge', 'Merge into target') - .option('-r, --remove [path,..]', 'Remove property') - .option('-c, --dot', 'Convert object to dotted-key/value pair') - .option('-s, --show', 'show all dotted paths') - .option('-v, --verbose', 'Be verbose') - .option('-d, --dry', 'Dry run do not modify files') - .parse(process.argv); - -function must(program, option) { - if(!program.hasOwnProperty(option)) { - console.log([ - 'The', option, 'is required' - ].join(' ')); - process.exit(1); - } -} +var x = program + .version(pkg.version) + .usage('[options]') + .option('-p, --pattern [pattern]', 'Files pattern to match or just the file') + .option('-f, --from [path,..]', 'From path') + .option('-t, --to [path,..]', 'To path (number of replacements must match --to values)') + .option('-m, --merge', 'Merge into target') + .option('-r, --remove [path,..]', 'Remove property') + .option('-c, --dot', 'Convert object to dotted-key/value pair') + .option('-s, --show', 'show all dotted paths') + .option('-v, --verbose', 'Be verbose') + .option('-d, --dry', 'Dry run do not modify files') + .action(function (options) { + must(options, 'pattern'); + if (!options.remove && !options.dot && !options.show) { + must(options, 'from'); + must(options, 'to'); + } + var g = new Glob(options.pattern, {}); -must(program, 'pattern'); + g.stream().on('data', processFile(options)); -if (!program.remove && !program.dot && !program.show) { - must(program, 'from'); - must(program, 'to'); -} + }) +program.parse(process.argv); + +function must(options, option) { -var g = glob(program.pattern); + if (!options.hasOwnProperty(option)) { + console.log([ + 'The', option, 'is required' + ].join(' ')); + process.exit(1); + } +} function finish(program, file, orig, json) { - return function(err) { - if (err) { - throw err; - } else { - if (program.verbose) { - if (orig !== JSON.stringify(json)) { - console.log(file + ': updated.'); + return function (err) { + if (err) { + throw err; } else { - console.log(file + ': no matches.'); + if (program.verbose) { + if (orig !== JSON.stringify(json)) { + console.log(file + ': updated.'); + } else { + console.log(file + ': no matches.'); + } + } } - } - } - }; + }; } function splim(path) { - return path.split(',') - .map(function(val) { return val.trim(); }); + return path.split(',') + .map(function (val) { + return val.trim(); + }); } -function processFile(file) { +function processFile(program) { + return function (file) { + fs.readFile(file, 'utf8', function (err, contents) { + var json; - fs.readFile(file, 'utf8', function(err, contents) { - var json; - - if (err) { - console.log(err); - return; - } - - try { - json = JSON.parse(contents); - - if(program.show) { - json = console.log(Object.keys(dotob.dot(json)).join('\n')); - process.exit() - } else if(program.dot) { - console.log(dotob.dot(json)); - process.exit() - } - - json = Array.isArray(json) ? json : [json]; - - if(program.remove) { - // support comma seperate list of removals - splim(program.remove) - .forEach(function(path) { - for (var j = 0; j < json.length; j++) { - dotob.remove(path, json[j]); + if (err) { + console.log(err); + return; } - }); - } else { - var from = splim(program.from); - var to = splim(program.to); - if (from.length === to.length) { - for (var i = 0; i < from.length; i++) { - for (var j = 0; j < json.length; j++) { - dotob.move( - from[i], to[i], json[j], program.merge - ); + + try { + json = JSON.parse(contents); + + if (program.show) { + json = console.log(Object.keys(dotob.dot(json)).join('\n')); + process.exit() + } else if (program.dot) { + console.log(dotob.dot(json)); + process.exit() + } + + json = Array.isArray(json) ? json : [json]; + + if (program.remove) { + // support comma seperate list of removals + splim(program.remove) + .forEach(function (path) { + for (var j = 0; j < json.length; j++) { + dotob.remove(path, json[j]); + } + }); + } else { + var from = splim(program.from); + var to = splim(program.to); + if (from.length === to.length) { + for (var i = 0; i < from.length; i++) { + for (var j = 0; j < json.length; j++) { + dotob.move( + from[i], to[i], json[j], program.merge + ); + } + } + } else { + console.error('--from and --to parameters are not of equal length'); + } + } + + if (program.dry) { + console.log(json); + finish(program, file, contents, json)(); + } else { + fs.writeFile(file, JSON.stringify(json, null, 2), finish( + program, file, contents, json + )); + } + } catch (e) { + console.log(file + ': '); + throw (e); } - } - } else { - console.error('--from and --to parameters are not of equal length'); - } - } - - if(program.dry) { - console.log(json); - finish(program, file, contents, json)(); - } else { - fs.writeFile(file, JSON.stringify(json, null, 2), finish( - program, file, contents, json - )); - } - } catch (e) { - console.log(file + ': '); - throw(e); + }); } - }); } - -g.on('match', processFile); diff --git a/package.json b/package.json index 3227bc3..1dd9790 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "dot" ], "dependencies": { - "commander": "^6.1.0", - "glob": "^7.1.6" + "glob": "^11.0.3", + "commander": "^14.0.1" }, "packageManager": "yarn@4.1.1" } From 6a7e3f7da77d9c5c85e5aedf10b85257a3c3ea01 Mon Sep 17 00:00:00 2001 From: Christian Proske Date: Wed, 15 Oct 2025 10:45:43 +0200 Subject: [PATCH 2/4] remove unused import --- bin/dot-object | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dot-object b/bin/dot-object index f6430f7..44c45e7 100755 --- a/bin/dot-object +++ b/bin/dot-object @@ -2,7 +2,7 @@ // vim: set filetype=javascript: 'use strict'; -var {globSync, Glob} = require('glob'); +var {Glob} = require('glob'); var fs = require('fs'); /** From 5d5bf410809e1f44cdba80538d72efa913b6b4ac Mon Sep 17 00:00:00 2001 From: Christian Proske Date: Wed, 15 Oct 2025 10:48:17 +0200 Subject: [PATCH 3/4] removed unused variable --- bin/dot-object | 227 +++++++++++++++++++++++++------------------------ 1 file changed, 115 insertions(+), 112 deletions(-) diff --git a/bin/dot-object b/bin/dot-object index 44c45e7..26bebff 100755 --- a/bin/dot-object +++ b/bin/dot-object @@ -1,138 +1,141 @@ #!/usr/bin/env node // vim: set filetype=javascript: -'use strict'; +'use strict' -var {Glob} = require('glob'); -var fs = require('fs'); +var { + globSync, + Glob +} = require('glob') +var fs = require('fs') /** * * dotob -f require -t dependencies.npm * */ -var dotob = require('../index.js'); -var {Command} = require('commander'); -var program = new Command(); -var pkg = require('../package.json'); - -var x = program - .version(pkg.version) - .usage('[options]') - .option('-p, --pattern [pattern]', 'Files pattern to match or just the file') - .option('-f, --from [path,..]', 'From path') - .option('-t, --to [path,..]', 'To path (number of replacements must match --to values)') - .option('-m, --merge', 'Merge into target') - .option('-r, --remove [path,..]', 'Remove property') - .option('-c, --dot', 'Convert object to dotted-key/value pair') - .option('-s, --show', 'show all dotted paths') - .option('-v, --verbose', 'Be verbose') - .option('-d, --dry', 'Dry run do not modify files') - .action(function (options) { - must(options, 'pattern'); - if (!options.remove && !options.dot && !options.show) { - must(options, 'from'); - must(options, 'to'); - } - var g = new Glob(options.pattern, {}); +var dotob = require('../index.js') +var { Command } = require('commander') +var program = new Command() +var pkg = require('../package.json') + +program + .version(pkg.version) + .usage('[options]') + .option('-p, --pattern [pattern]', 'Files pattern to match or just the file') + .option('-f, --from [path,..]', 'From path') + .option('-t, --to [path,..]', 'To path (number of replacements must match --to values)') + .option('-m, --merge', 'Merge into target') + .option('-r, --remove [path,..]', 'Remove property') + .option('-c, --dot', 'Convert object to dotted-key/value pair') + .option('-s, --show', 'show all dotted paths') + .option('-v, --verbose', 'Be verbose') + .option('-d, --dry', 'Dry run do not modify files') + .action(function (options) { + must(options, 'pattern') + if (!options.remove && !options.dot && !options.show) { + must(options, 'from') + must(options, 'to') + } + var g = new Glob(options.pattern, {}) - g.stream().on('data', processFile(options)); + g.stream().on('data', processFile(options)) - }) -program.parse(process.argv); + }) +program.parse(process.argv) -function must(options, option) { +function must (options, option) { - if (!options.hasOwnProperty(option)) { - console.log([ - 'The', option, 'is required' - ].join(' ')); - process.exit(1); - } + if (!options.hasOwnProperty(option)) { + console.log([ + 'The', option, 'is required' + ].join(' ')) + process.exit(1) + } } -function finish(program, file, orig, json) { +function finish (program, file, orig, json) { - return function (err) { - if (err) { - throw err; + return function (err) { + if (err) { + throw err + } else { + if (program.verbose) { + if (orig !== JSON.stringify(json)) { + console.log(file + ': updated.') } else { - if (program.verbose) { - if (orig !== JSON.stringify(json)) { - console.log(file + ': updated.'); - } else { - console.log(file + ': no matches.'); - } - } + console.log(file + ': no matches.') } - }; + } + } + } } -function splim(path) { - return path.split(',') - .map(function (val) { - return val.trim(); - }); +function splim (path) { + return path.split(',') + .map(function (val) { + return val.trim() + }) } -function processFile(program) { - return function (file) { - fs.readFile(file, 'utf8', function (err, contents) { - var json; +function processFile (program) { + return function (file) { + fs.readFile(file, 'utf8', function (err, contents) { + var json + + if (err) { + console.log(err) + return + } + + try { + json = JSON.parse(contents) + + if (program.show) { + json = console.log(Object.keys(dotob.dot(json)).join('\n')) + process.exit() + } else if (program.dot) { + console.log(dotob.dot(json)) + process.exit() + } + + json = Array.isArray(json) ? json : [json] - if (err) { - console.log(err); - return; + if (program.remove) { + // support comma seperate list of removals + splim(program.remove) + .forEach(function (path) { + for (var j = 0; j < json.length; j++) { + dotob.remove(path, json[j]) + } + }) + } else { + var from = splim(program.from) + var to = splim(program.to) + if (from.length === to.length) { + for (var i = 0; i < from.length; i++) { + for (var j = 0; j < json.length; j++) { + dotob.move( + from[i], to[i], json[j], program.merge + ) + } } + } else { + console.error('--from and --to parameters are not of equal length') + } + } - try { - json = JSON.parse(contents); - - if (program.show) { - json = console.log(Object.keys(dotob.dot(json)).join('\n')); - process.exit() - } else if (program.dot) { - console.log(dotob.dot(json)); - process.exit() - } - - json = Array.isArray(json) ? json : [json]; - - if (program.remove) { - // support comma seperate list of removals - splim(program.remove) - .forEach(function (path) { - for (var j = 0; j < json.length; j++) { - dotob.remove(path, json[j]); - } - }); - } else { - var from = splim(program.from); - var to = splim(program.to); - if (from.length === to.length) { - for (var i = 0; i < from.length; i++) { - for (var j = 0; j < json.length; j++) { - dotob.move( - from[i], to[i], json[j], program.merge - ); - } - } - } else { - console.error('--from and --to parameters are not of equal length'); - } - } - - if (program.dry) { - console.log(json); - finish(program, file, contents, json)(); - } else { - fs.writeFile(file, JSON.stringify(json, null, 2), finish( - program, file, contents, json - )); - } - } catch (e) { - console.log(file + ': '); - throw (e); - } - }); - } + if (program.dry) { + console.log(json) + finish(program, file, contents, json)() + } else { + fs.writeFile(file, JSON.stringify(json, null, 2), finish( + program, file, contents, json + )) + } + } catch (e) { + console.log(file + ': ') + throw (e) + } + }) + } } From 57247dda14f7c62f11bc47002ab177e1d942517b Mon Sep 17 00:00:00 2001 From: Christian Proske Date: Wed, 15 Oct 2025 10:52:58 +0200 Subject: [PATCH 4/4] removed unused import again --- bin/dot-object | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/dot-object b/bin/dot-object index 26bebff..167b8c6 100755 --- a/bin/dot-object +++ b/bin/dot-object @@ -2,10 +2,7 @@ // vim: set filetype=javascript: 'use strict' -var { - globSync, - Glob -} = require('glob') +var { Glob } = require('glob') var fs = require('fs') /**