(destinationDir, opts)
| 25 | }; |
| 26 | |
| 27 | const 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 | |
| 77 | const setupMessage = function () { |
| 78 | console.log('Creating app structure...'); |
no test coverage detected
searching dependent graphs…