src/spawn.js
// Output the chainspec of a node using `--raw` from a JSON file.
Output the chainspec of a node using `--raw` from a JSON file.
Output the chainspec of a node using ` -- raw ` from a JSON file .
async function generateChainSpecRaw(bin, chain) {
	return new Promise(function (resolve, reject) {
		let args = [
			"build-spec",
			"--chain=" + chain + '.json',
			"--raw",
		];
		p['spec'] = spawn(bin, args);
		let spec = fs.createWriteStream(`${chain}-raw.json`);
		p['spec'].stdout.pipe(spec)
		p['spec'].stderr.pipe(process.stderr)
		p['spec'].on('close', () => {
			resolve();
		});
		p['spec'].on('error', (err) => {
			reject(err);
		});
	})
}
async function generateChainSpecRaw ( bin , chain ) { return new Promise ( function ( resolve , reject ) { let args = [ "build-spec" , "--chain=" + chain + '.json' , "--raw" , ] ; p [ 'spec' ] = spawn ( bin , args ) ; let spec = fs . createWriteStream ( ` ${ chain } ` ) ; p [ 'spec' ] . stdout . pipe ( spec ) p [ 'spec' ] . stderr . pipe ( process . stderr ) p [ 'spec' ] . on ( 'close' , ( ) => { resolve ( ) ; } ) ; p [ 'spec' ] . on ( 'error' , ( err ) => { reject ( err ) ; } ) ; } ) }
Output the chainspec of a node using `--raw` from a JSON file.
Output the chainspec of a node using ` -- raw ` from a JSON file .
// `pipe` since it deals with flushing and  we need to guarantee that the data is flushed // before we resolve the promise.