MCPcopy Index your code
hub / github.com/react/react / main

Function main

packages/react-devtools-extensions/deploy.js:9–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7const {join} = require('path');
8const shell = require('shelljs');
9const main = async buildId => {
10 const root = join(__dirname, buildId);
11 const buildPath = join(root, 'build');
12
13 execSync(`node ${join(root, './build')}`, {
14 cwd: __dirname,
15 env: {
16 ...process.env,
17 NODE_ENV: 'production',
18 },
19 stdio: 'inherit',
20 });
21 shell.cp(join(root, 'now.json'), join(buildPath, 'now.json'));
22 const file = readFileSync(join(root, 'now.json'));
23 const json = JSON.parse(file);
24 const alias = json.alias[0];
25
26 const commit = execSync('git rev-parse HEAD').toString().trim().slice(0, 7);
27
28 let date = new Date();
29 date = `${date.toLocaleDateString()} – ${date.toLocaleTimeString()}`;
30
31 const installationInstructions =
32 buildId === 'chrome'
33 ? readFileSync(join(__dirname, 'deploy.chrome.html'))
34 : readFileSync(join(__dirname, 'deploy.firefox.html'));
35
36 let html = readFileSync(join(__dirname, 'deploy.html')).toString();
37 html = html.replace(/%commit%/g, commit);
38 html = html.replace(/%date%/g, date);
39 html = html.replace(/%installation%/, installationInstructions);
40
41 writeFileSync(join(buildPath, 'index.html'), html);
42
43 await exec(`now deploy && now alias ${alias}`, {
44 cwd: buildPath,
45 stdio: 'inherit',
46 });
47
48 console.log(`Deployed to https://${alias}.now.sh`);
49};
50
51module.exports = main;

Callers

nothing calls this directly

Calls 2

execFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected