MCPcopy Index your code
hub / github.com/SocketCluster/socketcluster / createSuccess

Function createSuccess

bin/actions/create.js:27–75  ·  view source on GitHub ↗
(destinationDir, opts)

Source from the content-addressed store, hash-verified

25};
26
27const createSuccess = (destinationDir, opts) => {
28 console.log(
29 'Installing app dependencies using npm. This could take a while...',
30 );
31
32 const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
33 const options = {
34 cwd: destinationDir,
35 maxBuffer: Infinity,
36 };
37
38 const npmProcess = spawn(npmCommand, ['install'], options);
39
40 npmProcess.stdout.on('data', (data) => {
41 process.stdout.write(data);
42 });
43
44 npmProcess.stderr.on('data', (data) => {
45 process.stderr.write(data);
46 });
47
48 npmProcess.on('close', (code) => {
49 const clientFileDestination = clientFileDestPath(destinationDir);
50 const clientFileSource = clientFileSourcePath(destinationDir);
51
52 if (code) {
53 opts.errorLog(
54 `Failed to install npm dependencies. Exited with code ${code}.`,
55 );
56 } else {
57 try {
58 fs.writeFileSync(
59 clientFileDestination,
60 fs.readFileSync(clientFileSource),
61 );
62 opts.successLog(
63 `SocketCluster app "${destinationDir}" was setup successfully.`,
64 );
65 } catch (err) {
66 opts.errorLog(
67 `Failed to copy file from "${clientFileSource}" to "${clientFileDestination}" - Try copying it manually.`,
68 code,
69 );
70 }
71 }
72 });
73
74 npmProcess.stdin.end();
75};
76
77const setupMessage = function () {
78 console.log('Creating app structure...');

Callers 2

confirmReplaceSetupFunction · 0.85
createFunction · 0.85

Calls 3

clientFileDestPathFunction · 0.85
clientFileSourcePathFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…