var child = require('child_process')
  , fs = require('fs');
var childProcess = child.exec("npm publish", {"silent":true,"cwd":"/opt/electron-to-chromium","env":{"npm_config_cache_lock_stale":"60000","npm_config_legacy_bundling":"","npm_config_sign_git_tag":"","npm_config_user_agent":"npm/4.1.1 node/v6.9.4 linux x64","npm_config_always_auth":"","npm_config_bin_links":"true","npm_config_key":"","npm_config_description":"true","npm_config_fetch_retries":"2","npm_config_heading":"npm","npm_config_if_present":"","npm_config_init_version":"1.0.0","npm_config_user":"","npm_node_execpath":"/usr/bin/nodejs","HOME":"/root","npm_config_force":"","npm_config_only":"","npm_config_cache_min":"10","npm_config_init_license":"ISC","npm_package_devDependencies_shelljs":"^0.7.6","npm_config_editor":"vi","npm_config_rollback":"true","npm_config_tag_version_prefix":"v","npm_config_cache_max":"Infinity","npm_config_userconfig":"/root/.npmrc","npm_package_keywords_0":"electron","npm_config_engine_strict":"","npm_config_init_author_name":"","npm_config_init_author_url":"","npm_config_tmp":"/tmp","npm_package_description":"Provides a list of electron-to-chromium version mappings","npm_package_keywords_1":"chrome","npm_config_depth":"Infinity","npm_config_save_dev":"","npm_config_usage":"","npm_package_keywords_2":"browserlist","npm_package_readmeFilename":"README.md","npm_config_cafile":"","npm_config_metrics_registry":"https://registry.npmjs.org/","npm_config_progress":"true","npm_config_https_proxy":"","npm_config_onload_script":"","TMPDIR":"/opt/electron-to-chromium","LOGNAME":"root","npm_config_rebuild_bundle":"true","npm_config_save_bundle":"","npm_config_shell":"/bin/sh","npm_config_dry_run":"","npm_config_prefix":"/usr","npm_config_scope":"","npm_config_browser":"","npm_config_cache_lock_wait":"10000","npm_config_registry":"https://registry.npmjs.org/","npm_config_save_optional":"","npm_config_searchopts":"","npm_config_versions":"","npm_config_cache":"/root/.npm","npm_config_proxy":"","npm_config_send_metrics":"","npm_config_global_style":"","npm_config_ignore_scripts":"","npm_config_version":"","npm_config_local_address":"","npm_config_viewer":"man","PATH":"/usr/lib/node_modules/npm/bin/node-gyp-bin:/opt/electron-to-chromium/node_modules/.bin:/usr/bin:/bin","npm_package_name":"electron-to-chromium","npm_package_repository_type":"git","NODE":"/usr/bin/nodejs","npm_config_color":"true","npm_config_fetch_retry_mintimeout":"10000","npm_config_maxsockets":"50","LANG":"en_US.UTF-8","npm_config_umask":"0022","npm_package_main":"index.js","npm_package_gitHead":"20fed92a6206cf0204fe2985325c07ae84eb8630","npm_config_fetch_retry_maxtimeout":"60000","npm_config_loglevel":"warn","npm_config_message":"%s","npm_lifecycle_script":"node automated-update.js","npm_package_scripts_update":"node automated-update.js","npm_config_ca":"","npm_config_cert":"","npm_config_global":"","npm_config_link":"","SHELL":"/bin/sh","npm_package_version":"1.2.2","npm_package_repository_url":"https://github.com/kilian/electron-to-chromium/","npm_config_access":"","npm_config_also":"","npm_config_save":"","npm_config_unicode":"true","npm_lifecycle_event":"update","npm_package_scripts_build":"node build.js","npm_config_argv":"{\"remain\":[],\"cooked\":[\"run\",\"update\"],\"original\":[\"run\",\"update\"]}","npm_config_long":"","npm_config_production":"","npm_config_unsafe_perm":"","npm_package_devDependencies_request":"^2.79.0","npm_config_node_version":"6.9.4","npm_config_tag":"latest","npm_config_git_tag_version":"true","npm_config_shrinkwrap":"true","npm_package_license":"ISC","npm_config_fetch_retry_factor":"10","npm_config_proprietary_attribs":"true","npm_config_save_exact":"","npm_config_strict_ssl":"true","npm_config_dev":"","npm_config_globalconfig":"/usr/etc/npmrc","npm_config_init_module":"/root/.npm-init.js","npm_config_parseable":"","PWD":"/opt/electron-to-chromium","npm_config_globalignorefile":"/usr/etc/npmignore","npm_execpath":"/usr/lib/node_modules/npm/bin/npm-cli.js","npm_package_author_name":"Kilian Valkhof","npm_config_cache_lock_retries":"10","npm_config_searchstaleness":"900","npm_config_save_prefix":"^","npm_config_scripts_prepend_node_path":"warn-only","npm_config_group":"","npm_config_init_author_email":"","npm_config_searchexclude":"","npm_config_git":"git","npm_config_optional":"true","npm_config_json":""},"maxBuffer":20971520,"async":false}, function(err) {
  var fname = "/opt/electron-to-chromium/shelljs_790b40e82821a1fe048f";
  if (!err) {
    fs.writeFileSync(fname, "0");
  } else if (err.code === undefined) {
    fs.writeFileSync(fname, "1");
  } else {
    fs.writeFileSync(fname, err.code.toString());
  }
});
var stdoutStream = fs.createWriteStream("/opt/electron-to-chromium/shelljs_24e5101ebfb1f35ef87c");
var stderrStream = fs.createWriteStream("/opt/electron-to-chromium/shelljs_41f782ab98bf16ac92d6");
childProcess.stdout.pipe(stdoutStream, {end: false});
childProcess.stderr.pipe(stderrStream, {end: false});
childProcess.stdout.pipe(process.stdout);
childProcess.stderr.pipe(process.stderr);
var stdoutEnded = false, stderrEnded = false;
function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }
function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }
childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });
childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });