Skip to content

Commit

Permalink
fix(browser-sync): update the mechanism to stop the server
Browse files Browse the repository at this point in the history
1. Stop application server with browser-sync api
2. Run the application in non-watch mode
  • Loading branch information
shahabganji authored and 3cp committed Sep 3, 2019
1 parent 1291be4 commit 3ffc7ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 2 additions & 3 deletions skeleton/cli-bundler/aurelia_project/tasks/run.ext
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ const run = gulp.series(
done => { watch(reload); done(); }
);

const shutdownAppServer = (code) =>{
const shutdownAppServer = () =>{
return new Promise(resolve => {
bs.exit();
process.exit(code || 0);
resolve();
});
};

export { run as default , shutdownAppServer };
export { run as default, serve , shutdownAppServer };
9 changes: 7 additions & 2 deletions skeleton/cypress/aurelia_project/tasks/cypress.ext
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import * as config from '../../cypress.config';
// @endif
import { CLIOptions } from 'aurelia-cli';
import * as project from '../aurelia.json';
// @if feat["cli-bundler"]
import { serve as runAppServer, shutdownAppServer } from './run';
// @endif
// @if feat.webpack
import { default as runAppServer, shutdownAppServer } from './run';
// @endif

const runCypress = (cb) => {
if (CLIOptions.hasFlag('run')) {
Expand All @@ -20,7 +25,7 @@ const runCypress = (cb) => {
shutdownAppServer().then(cb);
}
else {
shutdownAppServer(1)
shutdownAppServer()
.then(_ => {
cb('Tests failed');
});
Expand All @@ -34,8 +39,8 @@ const runCypress = (cb) => {

export default (cb) => {
if (CLIOptions.hasFlag('start')) {
runCypress(cb);
runAppServer();
runCypress(cb);
return;
}

Expand Down
8 changes: 7 additions & 1 deletion skeleton/protractor/aurelia_project/tasks/protractor.ext
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import * as gulp from 'gulp';
const {protractor, webdriver_update } = require('gulp-protractor');

import { CLIOptions } from 'aurelia-cli';
// @if feat["cli-bundler"]
import { serve as runAppServer, shutdownAppServer } from './run';
// @endif
// @if feat.webpack
import { default as runAppServer, shutdownAppServer } from './run';
// @endif


function runApp(cb) {
if (CLIOptions.hasFlag('start')) {
Expand All @@ -28,7 +34,7 @@ function runProtractor(cb) {
shutdownAppServer().then(cb);
})
.on('error', () => {
shutdownAppServer(1).then(cb);
shutdownAppServer().then(cb);
});
}

Expand Down

0 comments on commit 3ffc7ec

Please sign in to comment.