Skip to content

Commit ae6324c

Browse files
committed
new version
1 parent 2a12eea commit ae6324c

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules
2-
/yarn.lock
2+
/yarn.lock
3+
/package-lock.json

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

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+
815
## [1.2.1] - 2018-01-02
916

1017
### Fixed
@@ -40,6 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4047

4148
First version with basic features.
4249

50+
[1.3.0]: https://github.com/oscarotero/php-server-manager/compare/v1.2.1...v1.3.0
4351
[1.2.1]: https://github.com/oscarotero/php-server-manager/compare/v1.2.0...v1.2.1
4452
[1.2.0]: https://github.com/oscarotero/php-server-manager/compare/v1.1.0...v1.2.0
4553
[1.1.0]: https://github.com/oscarotero/php-server-manager/compare/v1.0.0...v1.1.0

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,21 @@ const server = new PHPServer({
5252
server.run();
5353
```
5454

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+
5563
## Use with gulp
5664

5765
```js
58-
gulp.task('php-server', done => {
59-
const server = new PHPServer({
66+
gulp.task('php-server', () =>
67+
PHPServer.start({
6068
directory: 'public',
6169
script: 'public/index.php'
62-
});
63-
64-
server.run(done);
65-
});
70+
})
71+
);
6672
```

index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ const spawn = require('child_process').spawn;
22
const http = require('http');
33

44
module.exports = class PHPServer {
5+
static start(config, cb) {
6+
const server = new PHPServer(config);
7+
8+
return server.run(cb);
9+
}
10+
511
constructor(config) {
612
this.php = 'php';
713
this.host = '127.0.0.1';
@@ -61,17 +67,15 @@ module.exports = class PHPServer {
6167
);
6268

6369
if (cb) {
64-
checkServer(this.host, this.port, cb);
70+
checkServer(this.host, this.port, () => cb(this));
6571
} else {
6672
return new Promise((resolve, reject) => {
6773
try {
68-
checkServer(this.host, this.port, () => {
69-
resolve()
70-
})
74+
checkServer(this.host, this.port, () => resolve(this));
7175
} catch (e) {
72-
reject(e)
76+
reject(e);
7377
}
74-
})
78+
});
7579
}
7680
}
7781

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "php-server-manager",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"description": "Manage PHP built-in servers in node",
55
"main": "index.js",
66
"author": "Oscar Otero",
@@ -22,7 +22,7 @@
2222
"url": "https://github.com/oscarotero/php-server-manager/issues"
2323
},
2424
"devDependencies": {
25-
"mocha": "^4.0.1",
26-
"prettier": "^1.8.2"
25+
"mocha": "^5.0.4",
26+
"prettier": "^1.11.1"
2727
}
2828
}

0 commit comments

Comments
 (0)