Skip to content

Instantly share code, notes, and snippets.

@iamhosseindhv
Created July 4, 2018 11:42
Show Gist options
  • Select an option

  • Save iamhosseindhv/24d6558a55942521af67c71a70e12db5 to your computer and use it in GitHub Desktop.

Select an option

Save iamhosseindhv/24d6558a55942521af67c71a70e12db5 to your computer and use it in GitHub Desktop.
Simple Node.js script to edit JSON files
var fs = require('fs');
const inputPath = 'composer.json';
const outputPath = 'composer.json';
var composerfile;
fs.readFile(inputPath, 'utf8', function (err, data) {
if (err) throw err;
composerfile = JSON.parse(data);
composerfile.config['vendor-dir'] = "./../path-to-vendor";
// delete composerfile.config['vendor-dir'];
fs.writeFileSync(outputPath, JSON.stringify(composerfile, null, 2) , 'utf-8');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment