Skip to content

Commit c8e1897

Browse files
giladgrayadidahiya
authored andcommittedJan 30, 2017
Fix table package distribution and add regression test (#574)
- new gulp `test-dist` task asserts that main files exist for each package.json - revert table tsconfig change - add tsconfig.json to table/preview that extends its parent so those files can be compiled (hooray TS 2.1)
1 parent 0593d22 commit c8e1897

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed
 

‎gulp/aliases.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = (gulp) => {
2222
gulp.task("build", (done) => rs("clean", "compile", "webpack-compile-docs", done));
2323

2424
// build code, run unit tests, terminate
25-
gulp.task("test", ["karma"]);
25+
gulp.task("test", ["test-dist", "karma"]);
2626

2727
// compile code and start watching for development
2828
gulp.task("default", (done) => rs("clean", "compile", "docs", "watch", done));

‎gulp/dist.js

+30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"use strict";
55

66
module.exports = (gulp, plugins, blueprint) => {
7+
const fs = require("fs");
78
const path = require("path");
89
const mergeStream = require("merge-stream");
910

@@ -26,4 +27,33 @@ module.exports = (gulp, plugins, blueprint) => {
2627
return mergeStream(streams);
2728
});
2829
});
30+
31+
// asserts that all main fields in package.json reference existing files
32+
function testDist(project) {
33+
const pkgJson = require(path.resolve(project.cwd, "package.json"));
34+
const promises = ["main", "style", "typings"]
35+
.filter((field) => pkgJson[field] !== undefined)
36+
.map((field) => {
37+
const filePath = path.resolve(project.cwd, pkgJson[field]);
38+
return new Promise((resolve, reject) => {
39+
// non-existent file will callback with err; we don't care about actual contents
40+
fs.readFile(filePath, (err) => {
41+
if (err) {
42+
reject(`${pkgJson.name}: "${field}" not found (${pkgJson[field]})`);
43+
} else {
44+
resolve();
45+
}
46+
});
47+
});
48+
});
49+
return Promise.all(promises);
50+
}
51+
52+
const testDistTasks = blueprint.projects.map((project) => {
53+
const name = `test-dist-${project.id}`;
54+
gulp.task(name, () => testDist(project));
55+
return name;
56+
});
57+
58+
gulp.task("test-dist", testDistTasks);
2959
};

‎packages/table/preview/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../tsconfig",
3+
"include": [
4+
"*.*"
5+
],
6+
"exclude": [
7+
"dist"
8+
]
9+
}

‎packages/table/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"target": "es5"
2323
},
2424
"include": [
25-
"preview/*",
25+
"preview/*.d.ts",
2626
"src/**/*"
2727
],
2828
"exclude": [

0 commit comments

Comments
 (0)