| 1 | #!/usr/bin/env node |
| 2 | |
| 3 | /** |
| 4 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 5 | * |
| 6 | * This source code is licensed under the MIT license found in the |
| 7 | * LICENSE file in the root directory of this source tree. |
| 8 | * |
| 9 | * @flow |
| 10 | */ |
| 11 | |
| 12 | const electron = require('electron'); |
| 13 | const spawn = require('cross-spawn'); |
| 14 | const argv = process.argv.slice(2); |
| 15 | const pkg = require('./package.json'); |
| 16 | const updateNotifier = require('update-notifier'); |
| 17 | |
| 18 | // Notify if there's an update in 7 days' interval |
| 19 | const notifier = updateNotifier({ |
| 20 | pkg, |
| 21 | updateCheckInterval: 1000 * 60 * 60 * 24 * 7, |
| 22 | }); |
| 23 | |
| 24 | if (notifier.update) { |
| 25 | const updateMsg = |
| 26 | `Update available ${notifier.update.current} -> ${notifier.update.latest}` + |
| 27 | '\nTo update:' + |
| 28 | '\n"npm i [-g] react-devtools" or "yarn add react-devtools"'; |
| 29 | notifier.notify({defer: false, message: updateMsg}); |
| 30 | } |
| 31 | |
| 32 | const result = spawn.sync(electron, [require.resolve('./app')].concat(argv), { |
| 33 | stdio: 'ignore', |
| 34 | }); |
| 35 | |
| 36 | process.exit(result.status); |