File tree 5 files changed +35
-16
lines changed
5 files changed +35
-16
lines changed Original file line number Diff line number Diff line change 1
1
/node_modules
2
- /yarn.lock
2
+ /yarn.lock
3
+ /package-lock.json
Original file line number Diff line number Diff line change @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
6
6
and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
7
7
8
+ ## [ 1.3.0] - 2018-03-07
9
+
10
+ ### Added
11
+
12
+ - Static function ` PHPServer.start() ` as a shortcut to ` new PHPServer().run() ` .
13
+ - The callback / promise have the ` PHPServer ` instance as first argument
14
+
8
15
## [ 1.2.1] - 2018-01-02
9
16
10
17
### Fixed
@@ -40,6 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
40
47
41
48
First version with basic features.
42
49
50
+ [ 1.3.0 ] : https://github.com/oscarotero/php-server-manager/compare/v1.2.1...v1.3.0
43
51
[ 1.2.1 ] : https://github.com/oscarotero/php-server-manager/compare/v1.2.0...v1.2.1
44
52
[ 1.2.0 ] : https://github.com/oscarotero/php-server-manager/compare/v1.1.0...v1.2.0
45
53
[ 1.1.0 ] : https://github.com/oscarotero/php-server-manager/compare/v1.0.0...v1.1.0
Original file line number Diff line number Diff line change @@ -52,15 +52,21 @@ const server = new PHPServer({
52
52
server .run ();
53
53
```
54
54
55
+ ## Quick use
56
+
57
+ You can use the static function ` start() ` to create and run a PHPServer in a single line:
58
+
59
+ ``` js
60
+ PHPServer .start ();
61
+ ```
62
+
55
63
## Use with gulp
56
64
57
65
``` js
58
- gulp .task (' php-server' , done => {
59
- const server = new PHPServer ({
66
+ gulp .task (' php-server' , () =>
67
+ PHPServer . start ({
60
68
directory: ' public' ,
61
69
script: ' public/index.php'
62
- });
63
-
64
- server .run (done);
65
- });
70
+ })
71
+ );
66
72
```
Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ const spawn = require('child_process').spawn;
2
2
const http = require ( 'http' ) ;
3
3
4
4
module . exports = class PHPServer {
5
+ static start ( config , cb ) {
6
+ const server = new PHPServer ( config ) ;
7
+
8
+ return server . run ( cb ) ;
9
+ }
10
+
5
11
constructor ( config ) {
6
12
this . php = 'php' ;
7
13
this . host = '127.0.0.1' ;
@@ -61,17 +67,15 @@ module.exports = class PHPServer {
61
67
) ;
62
68
63
69
if ( cb ) {
64
- checkServer ( this . host , this . port , cb ) ;
70
+ checkServer ( this . host , this . port , ( ) => cb ( this ) ) ;
65
71
} else {
66
72
return new Promise ( ( resolve , reject ) => {
67
73
try {
68
- checkServer ( this . host , this . port , ( ) => {
69
- resolve ( )
70
- } )
74
+ checkServer ( this . host , this . port , ( ) => resolve ( this ) ) ;
71
75
} catch ( e ) {
72
- reject ( e )
76
+ reject ( e ) ;
73
77
}
74
- } )
78
+ } ) ;
75
79
}
76
80
}
77
81
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " php-server-manager" ,
3
- "version" : " 1.2.1 " ,
3
+ "version" : " 1.3.0 " ,
4
4
"description" : " Manage PHP built-in servers in node" ,
5
5
"main" : " index.js" ,
6
6
"author" : " Oscar Otero" ,
22
22
"url" : " https://github.com/oscarotero/php-server-manager/issues"
23
23
},
24
24
"devDependencies" : {
25
- "mocha" : " ^4 .0.1 " ,
26
- "prettier" : " ^1.8.2 "
25
+ "mocha" : " ^5 .0.4 " ,
26
+ "prettier" : " ^1.11.1 "
27
27
}
28
28
}
You can’t perform that action at this time.
0 commit comments