Skip to content

Commit 89f521e

Browse files
filipesilvajohannes.werner
authored and
johannes.werner
committed
fix(build): re-add support for sourceDir (angular#1378)
1 parent 83c86c2 commit 89f521e

File tree

3 files changed

+7
-39
lines changed

3 files changed

+7
-39
lines changed

addon/ng2/models/webpack-build-test.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import * as webpack from 'webpack';
2+
import { CliConfig } from './config';
23

34
const path = require('path');
45

5-
export const getWebpackTestConfig = function(projectRoot: string) {
6+
export const getWebpackTestConfig = function(projectRoot: string, sourceDir: string) {
67
return {
78
devtool: 'inline-source-map',
89
context: path.resolve(__dirname, './'),
910
resolve: {
1011
extensions: ['', '.ts', '.js'],
11-
root: path.resolve(projectRoot, './src')
12+
root: path.resolve(projectRoot, `./${sourceDir}`)
1213
},
1314
entry: {
14-
test: path.resolve(projectRoot, './src/test.ts')
15+
test: path.resolve(projectRoot, `./${sourceDir}/test.ts`)
1516
},
1617
output: {
1718
path: './dist.test',
@@ -43,7 +44,7 @@ export const getWebpackTestConfig = function(projectRoot: string) {
4344
loader: 'awesome-typescript-loader',
4445
query: {
4546
useWebpackText: true,
46-
tsconfig: path.resolve(projectRoot, './src/tsconfig.json'),
47+
tsconfig: path.resolve(projectRoot, `./${sourceDir}/tsconfig.json`),
4748
module: "commonjs",
4849
target: "es5",
4950
useForkChecker: true,
@@ -62,7 +63,7 @@ export const getWebpackTestConfig = function(projectRoot: string) {
6263
{ test: /\.less$/, loaders: ['raw-loader', 'postcss-loader', 'less-loader'] },
6364
{ test: /\.scss$/, loaders: ['raw-loader', 'postcss-loader', 'sass-loader'] },
6465
{ test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'},
65-
{ test: /\.html$/, loader: 'raw-loader', exclude: [path.resolve(projectRoot, 'src/index.html')] }
66+
{ test: /\.html$/, loader: 'raw-loader', exclude: [path.resolve(projectRoot, `./${sourceDir}/index.html`)] }
6667
],
6768
postLoaders: [
6869
{
@@ -77,7 +78,7 @@ export const getWebpackTestConfig = function(projectRoot: string) {
7778
tslint: {
7879
emitErrors: false,
7980
failOnHint: false,
80-
resourcePath: 'src'
81+
resourcePath: `./${sourceDir}`
8182
},
8283
node: {
8384
global: 'window',

addon/ng2/tasks/test.js

Whitespace-only changes.

addon/ng2/tasks/test.ts

-33
Original file line numberDiff line numberDiff line change
@@ -1,33 +0,0 @@
1-
import * as Promise from 'ember-cli/lib/ext/promise';
2-
import * as Task from 'ember-cli/lib/models/task';
3-
import * as path from 'path';
4-
import { getWebpackTestConfig } from '../models/webpack-build-test';
5-
6-
// require dependencies within the target project
7-
function requireDependency(root, moduleName) {
8-
const packageJson = require(path.join(root, 'node_modules', moduleName, 'package.json'));
9-
const main = path.normalize(packageJson.main);
10-
return require(path.join(root, 'node_modules', moduleName, main));
11-
}
12-
13-
module.exports = Task.extend({
14-
run: function (options) {
15-
const projectRoot = this.project.root;
16-
return new Promise((resolve) => {
17-
const karma = requireDependency(projectRoot, 'karma');
18-
const karmaConfig = path.join(projectRoot, this.project.ngConfig.test.karma.config);
19-
20-
// Convert browsers from a string to an array
21-
if (options.browsers) {
22-
options.browsers = options.browsers.split(',');
23-
}
24-
25-
// Assign additional karmaConfig options to the local ngapp config
26-
options.configFile = karmaConfig;
27-
28-
// :shipit:
29-
const karmaServer = new karma.Server(options, resolve);
30-
karmaServer.start();
31-
});
32-
}
33-
});

0 commit comments

Comments
 (0)