Skip to content

Commit

Permalink
Merge pull request #183 from al-haras/master
Browse files Browse the repository at this point in the history
add ability to use data to read from file with instance:export
  • Loading branch information
tobiaslohr authored May 26, 2021
2 parents a16175e + fa9f032 commit 461689a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ program
.option('-i, --instance <instance>','Instance to run the export on. Can be an instance alias. ' +
'If not specified the currently configured instance will be used.')
.option('-j, --json', 'Formats the output in json')
.option('-d, --data <data>', 'Set of data in JSON format to export')
.option('-d, --data <data>', 'Set of data as parameter or file specified in JSON format for what to export')
.option('-f, --file <file>', 'File to store exported data to, relative to impex/src/instance')
.option('-j, --json', 'Formats the output in json')
.option('-s, --sync', 'Operates in synchronous mode and waits until the operation has been finished.')
Expand All @@ -947,7 +947,7 @@ program
.description('Run an instance export')
.action(function(options) {
var instance = require('./lib/instance').getInstance(options.instance);
var data = ( options.data ? JSON.parse(options.data) : null );
var data = require('./lib/export').readExportJson(options.data);
if (!data) {
this.missingArgument('data');
return;
Expand Down
13 changes: 13 additions & 0 deletions lib/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
var fs = require('fs');

module.exports.readExportJson = function readExportJson(exportJson = '') {
if (!exportJson) return;
var rawdata = fs.existsSync(exportJson) ? fs.readFileSync(exportJson) : exportJson;
return JSON.parse(rawdata)
}

0 comments on commit 461689a

Please sign in to comment.