Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | var path = require('path'); |
||
16 | }).then(function() { |
||
17 | var nextCommand = ssh.mkdir('/var/www/auth.local/src/'); |
||
18 | // @see: https://github.com/steelbrain/node-ssh/blob/master/src/index.js |
||
19 | nextCommand.then( function(){ |
||
20 | ssh.exec('rm', ['-rf', 'public'], { cwd: '/var/www/auth.local', stream: 'both' }).then( function(both){ |
||
21 | ssh.exec('ln', ['-s','web','public'], { cwd: '/var/www/auth.local', stream: 'both' }).then( function(both){ |
||
22 | ssh.dispose(); |
||
23 | process.stdout.write("prepare dir COMPLETED.\n"); |
||
24 | |||
25 | process.stdout.write("Start rsync src.\n"); |
||
26 | |||
27 | rsync({ |
||
28 | src: "./applications/externalLogin/", |
||
29 | dest: "[email protected]:/var/www/auth.local/", |
||
30 | ssh: true, |
||
31 | privateKey: './server/plays/ssh/developer.key', |
||
32 | port: 2222, |
||
33 | exclude: [ 'test', '.DS_Store', 'phpunit.xml', 'README.md', 'vendor' ], |
||
34 | recursive: true, |
||
35 | deleteAll: false //senno elimina log! |
||
36 | },function (error,stdout,stderr,cmd) { |
||
37 | if ( error ) { |
||
38 | process.stderr.write('CMD: '+cmd+"\n"); |
||
39 | process.stderr.write(chalk.red(error.message)+"\n"); |
||
40 | process.exit(1); |
||
41 | } |
||
42 | }); |
||
43 | |||
44 | process.stdout.write("Composer install.\n"); |
||
45 | |||
46 | ssh.connect({ |
||
47 | host: 'www.d1b0.local', |
||
48 | username: 'developer', |
||
49 | privateKey: './server/plays/ssh/developer.key', |
||
50 | port: 2222 |
||
51 | }).then(function() { |
||
52 | ssh.exec('composer', ['install', '--no-dev', '--optimize-autoloader', '--no-interaction', '--no-progress', '--no-scripts'], { cwd: '/var/www/auth.local/', stream: 'both' }).then(function(both) { |
||
53 | process.stdout.write(chalk.cyan(both.stdout)+"\n"); |
||
54 | if ( both.code === 0 ){ |
||
55 | process.stdout.write(chalk.cyan(both.stderr)+"\n"); |
||
56 | } else { |
||
57 | process.stdout.write(chalk.red(both.stderr)+"\n"); |
||
58 | process.exit(1); |
||
59 | } |
||
60 | process.stdout.write("Deploy COMPLETED.\n"); |
||
61 | ssh.dispose(); |
||
62 | }); |
||
63 | }); |
||
64 | |||
65 | }); |
||
66 | }); |
||
67 | }); |
||
68 | }); |
||
69 |