Skip to content
Permalink
Browse files

fix(webpack): new release check

Additionally small refactor in package manager to easily export NPM
and Yarn. Added a new method `run` in base package manager.
  • Loading branch information...
Sayan751 committed Jul 29, 2019
1 parent 76ffaef commit a217fec9f9da9eac8159a5274b053f513b77c837
@@ -65,6 +65,8 @@ module.exports = function(suite) {

if (applicable(features, 'webpack')) {
steps.push(
new tests.webpack.AuBuildDoesNotThrowCommandLineErrors(),
new tests.webpack.AuBuildStartsWebpackInWatchMode(),
new tests.webpack.AuRunDoesNotThrowCommandLineErrors(),
new tests.webpack.AuRunLaunchesServer(),
new tests.webpack.AuRunRendersPage(),
@@ -0,0 +1,64 @@
const Test = require('../test');
const ExecuteCommand = require('../../tasks/execute-command');
const path = require('path');
const fs = require('fs');

class AuBuildDoesNotThrowCommandLineErrors extends Test {
constructor() {
super('au build does not throw commandline errors');
}

onOutput(message) {
this.debug(message);

if (message.toLowerCase().indexOf('error') > -1) {
this.executeCommand.stop();
this.fail();
} else if (isBuildCompletedMessage(message)) {
this.success();
this.executeCommand.stop();
}
}

execute() {
this.executeCommand = new ExecuteCommand('au', ['build'], (msg) => this.onOutput(msg));
return this.executeCommand.executeAsNodeScript();
}
}

class AuBuildStartsWebpackInWatchMode extends Test {
constructor(fileToChange) {
super('au build --watch starts webpack in watch mode');

this.fileToChange = fileToChange || path.join('src', 'app.html');
this.firstBuildCompleted = false;
}

onOutput(message) {
this.debug(message);

if (message.toLowerCase().indexOf('error') > -1) {
this.executeCommand.stop();
this.fail();
} else if (message.indexOf('webpack is watching the files') > -1) {
this.success();
this.executeCommand.stop();
}
}

execute(context) {
this.context = context;

this.executeCommand = new ExecuteCommand('au', ['build', '--watch'], (msg) => this.onOutput(msg));
return this.executeCommand.executeAsNodeScript();
}
}

function isBuildCompletedMessage(msg) {
return msg.indexOf('Built at') > -1;
}

module.exports = {
AuBuildDoesNotThrowCommandLineErrors,
AuBuildStartsWebpackInWatchMode
};
@@ -1,3 +1,4 @@
module.exports = {
...require('./au-run')
...require('./au-run'),
...require('./au-build')
};
@@ -8,3 +8,5 @@ exports.ProjectItem = require('./project-item').ProjectItem;
exports.build = require('./build');
exports.Configuration = require('./configuration').Configuration;
exports.reportWebpackReadiness = require('./build/webpack-reporter');
exports.NPM = require('./package-managers/npm').NPM;
exports.Yarn = require('./package-managers/yarn').Yarn;
@@ -7,10 +7,14 @@ exports.BasePackageManager = class {
}

install(packages = [], workingDirectory = process.cwd(), command = 'install') {
return this.run(command, packages, workingDirectory);
}

run(command, args = [], workingDirectory = process.cwd()) {
return new Promise((resolve, reject) => {
spawn(
this.getExecutablePath(workingDirectory),
[command, ...packages],
[command, ...args],
{ stdio: 'inherit', cwd: workingDirectory }
)
.on('close', resolve)
@@ -1,8 +1,8 @@
import { NPM } from 'aurelia-cli/lib/package-managers/npm';
import { NPM } from 'aurelia-cli';

export default function() {
console.log('`au build` is an alias of the `npm run build`, you may use either of those; see README for more details.');

const args = process.argv.slice(3);
return (new NPM()).install(['--', ...args], process.cwd(), 'run');
return (new NPM()).run('run', ['build', '--', ...args]);
}
@@ -1,8 +1,8 @@
import { NPM } from 'aurelia-cli/lib/package-managers/npm';
import { NPM } from 'aurelia-cli';

export default function() {
console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.');

const args = process.argv.slice(3);
return (new NPM()).install(['--', ...args], process.cwd(), 'start');
return (new NPM()).run('start',['--', ...args]);
}

0 comments on commit a217fec

Please sign in to comment.
You can’t perform that action at this time.