Skip to content

Commit

Permalink
Make artifactpath a webpack config setting instead of a jester one
Browse files Browse the repository at this point in the history
This has the side-effect that jester no longer clears the directory before generating artifacts.
  • Loading branch information
barbara honhoff committed Apr 2, 2015
1 parent 4a6e0f2 commit 5fed609
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 25 deletions.
3 changes: 1 addition & 2 deletions jester.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"readme": "./readme.md",
"entryGlob": "app/features/*/feature.js",
"karmaPath": "./build/karma/",
"artifactPath": "./build/artifacts",
"karmaOptions": {
"proxies": {},
"browsers": [
Expand Down Expand Up @@ -143,4 +142,4 @@
"no-bitwise": 1,
"no-plusplus": 0
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jester-tester",
"description": "Get your project tested and out there with minimal fuss.",
"repository": "https://github.com/jauco/jester",
"version": "3.0.0-alpha8",
"version": "3.0.0-alpha9",
"author": "Jauco Noordzij <[email protected]>",
"bin": {
"jester-watch": "./src/bin/jester-watch.js",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/jester-batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var loadConfig = require("../lib/loadConfig"),

var config = loadConfig();

rebuildProject(config.webpackOptions, config.fullEntryGlob, config.artifactPath, config.webpackWarningFilters)
rebuildProject(config.webpackOptions, config.fullEntryGlob, config.webpackWarningFilters)
.then(function() {
if(config.srcPath && config.apiDocPath) {
return rebuildDocumentation(config.srcPath, config.apiDocPath, config.jsdocConf, config.readme);
Expand Down
6 changes: 3 additions & 3 deletions src/bin/jester-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var fs = require("fs"),
p = require("path");

var FEATURES_PATH = "features/";
var ARTIFACT_PATH = "./build/artifacts";

var defaultConf = {
eslintRulesDir: "./eslint-rules/",
Expand All @@ -14,7 +15,6 @@ var defaultConf = {
readme: "./readme.md",
entryGlob: FEATURES_PATH + "*/feature.js",
karmaPath: "./build/karma/",
artifactPath: "./build/artifacts",
karmaOptions: {
proxies: {},
browsers: ['Chrome', 'Firefox', 'IE', 'PhantomJS'],
Expand Down Expand Up @@ -48,7 +48,7 @@ var jester = require("jester-tester");\n\
module.exports = jester.deepMergeForWebpack({\n\
//entry is provided by jester\n\
output: {\n\
//outputpath is provided by jester\n\
path: ' + json.stringify(ARTIFACT_PATH) + ', \n\
filename: "[name].min.js",\n\
chunkFilename: "[id].chunk.js",\n\
namedChunkFilename: "[name].chunk.js"\n\
Expand All @@ -73,7 +73,7 @@ mkdirp(p.resolve(defaultConf.karmaPath));
mkdirp(p.join(defaultConf.srcPath, FEATURES_PATH));
mkdirp(p.join(defaultConf.srcPath, 'lib'));
mkdirp(p.join(defaultConf.srcPath, 'app', 'domain'));
mkdirp(p.resolve(defaultConf.artifactPath));
mkdirp(p.resolve(ARTIFACT_PATH));

mkdirp(p.resolve(defaultConf.apiDocPath));

Expand Down
2 changes: 1 addition & 1 deletion src/bin/jester-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function startWatching() {
}

if (filePath.length > 3 && filePath.substr(-3) === ".js") {
var build = rebuildProject(config.webpackOptions, config.fullEntryGlob, config.artifactPath, config.webpackWarningFilters);
var build = rebuildProject(config.webpackOptions, config.fullEntryGlob, config.webpackWarningFilters);
if (isReallyFileChangeEvent(changeType, fileCurrentStat, filePreviousStat)) {
when.join(build, runTests(filePath)).done(function(){});
} else {
Expand Down
5 changes: 0 additions & 5 deletions src/lib/api.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"use strict";

var config = require("./loadConfig");

module.exports.injectable = require("../injectable");
module.exports.MINIMAL_REQUIRED_CONFIG = {
output: {
path: config.artifactPath
},
devtool: "#source-map"
};
module.exports.deepMergeForWebpack = require("deepmerge");
8 changes: 5 additions & 3 deletions src/lib/createTestFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ var webpack = require("./webpackPromise"),
p = require("path"),
stripTestExtensions = require("./testFileHelpers").stripTestExtensions;

function createEntryModules(karmaPath, srcPath, filenames) {
function createEntryModules(srcPath, filenames) {
var entryModules = {};
if (typeof filenames === "string") {
filenames = [filenames];
}

filenames.forEach(function(file) {
var featurename = require("path").relative(srcPath, stripTestExtensions(file)).replace(/\//g, "_");
entryModules[p.join(karmaPath, featurename)] = file;
entryModules[featurename] = file;
console.log(" * " + featurename + " (" + file + ")." );
});

Expand All @@ -21,7 +21,9 @@ function createEntryModules(karmaPath, srcPath, filenames) {

module.exports = function createTestFile(filenames, srcPath, webpackConfig, karmaPath, webpackWarningFilters) {
var config = Object.create(webpackConfig);
config.entry = createEntryModules(karmaPath, srcPath, filenames);
config.output = Object.create(webpackConfig.output);
config.output.path = karmaPath;
config.entry = createEntryModules(srcPath, filenames);//fixme output may be null
config.output = Object.create(config.output || {});
config.output.filename = "[name].karmatest.js";
return webpack(config).then(function(stats) {
Expand Down
1 change: 0 additions & 1 deletion src/lib/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = function loadConfig() {
config.eslintRulesDir = p.resolve(config.eslintRulesDir);
config.srcPath = p.resolve(config.srcPath);
config.karmaPath = p.resolve(config.karmaPath);
config.artifactPath = p.resolve(config.artifactPath);
config.fullEntryGlob = require("path").join(config.srcPath, config.entryGlob);
config.webpackOptions = require(p.resolve("webpack.config.js"));
config.configLocation = CONFIG_LOCATION;
Expand Down
13 changes: 5 additions & 8 deletions src/lib/rebuildProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@ var glob = require("../lib/globPromise"),
handleWebpackResult = require("./handleWebpackResult"),
p = require("path");

function createEntryModules(artifactPath, featureFiles) {
function createEntryModules(featureFiles) {
var entryModules = {};

featureFiles.forEach(function (file) {
var featurename = p.basename(p.dirname(file));
entryModules[p.join(artifactPath, featurename)] = file;
entryModules[featurename] = file;
console.log(" * " + featurename + " (" + file + ")." );
});

return entryModules;
}

module.exports = function rebuildProject(webpackConfig, entryGlob, artifactPath, webpackWarningFilters) {
return clearDir(artifactPath)
.then(function filesCleared() {
return glob(entryGlob);
})
module.exports = function rebuildProject(webpackConfig, entryGlob, webpackWarningFilters) {
return glob(entryGlob)
.then(function (featureFiles) {
var config = Object.create(webpackConfig);
config.entry = createEntryModules(artifactPath, featureFiles);
config.entry = createEntryModules(featureFiles);
return webpack(config);
})
.then(function (stats){
Expand Down

0 comments on commit 5fed609

Please sign in to comment.