Skip to content

Commit ad0a44e

Browse files
committed
Inital commit.
0 parents  commit ad0a44e

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

README.md

Whitespace-only changes.

core-tests.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Write your tests here!
2+
// Here is an example.
3+
Tinytest.add('example', function (test) {
4+
test.equal(true, true);
5+
});

package.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Package.describe({
2+
name: 'pipeline:core',
3+
version: '0.0.1',
4+
summary: 'Build Pipeline',
5+
git: 'https://github.com/MeteorPipeline/core',
6+
documentation: 'README.md'
7+
});
8+
9+
Package.onUse(function(api) {
10+
api.use('isobuild:compiler-plugin@1.0.0');
11+
api.use(['caching-compiler', 'ecmascript', 'underscore']);
12+
api.addFiles('pipeline.js');
13+
api.export('Pipeline');
14+
});
15+
16+
Package.onTest(function(api) {
17+
api.use(["tinytest", "underscore"]);
18+
api.use(["pipeline:core"]);
19+
});

pipeline.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
class InputPipelineFile {
2+
constructor(file) {
3+
this.original = file;
4+
_.extend(this, _.omit(file, 'getContentsAsString'));
5+
}
6+
getContentsAsString() {
7+
if (!this._content) {
8+
this._content = this.original.getContentsAsString(arguments);
9+
}
10+
return this._content;
11+
}
12+
setContentAsString(content) {
13+
this._content = content;
14+
}
15+
};
16+
17+
Pipeline = class PipelineClass {
18+
constructor() {
19+
this.pipeline = [];
20+
}
21+
compileOneFile(_inputFiles) {
22+
inputFiles = [];
23+
for(let file of _inputFiles) {
24+
inputFiles.push(new InputPipelineFile(file));
25+
}
26+
for(let step of this.pipeline) {
27+
if (step.compileOneFile) {
28+
step.compileOneFile(inputFiles);
29+
}
30+
}
31+
}
32+
processFilesForTarget(_inputFiles) {
33+
inputFiles = [];
34+
for(let file of _inputFiles) {
35+
inputFiles.push(new InputPipelineFile(file));
36+
}
37+
for(let step of this.pipeline) {
38+
if (step.processFilesForTarget) {
39+
step.processFilesForTarget(inputFiles);
40+
}
41+
}
42+
}
43+
setDiskCacheDirectory(diskCache) {
44+
let step = this.pipeline[this.pipeline.length - 1];
45+
if (step && step.setDiskCacheDirectory) {
46+
return step.setDiskCacheDirectory(diskCache);
47+
}
48+
}
49+
sourceMapSize(sm) {
50+
let step = this.pipeline[this.pipeline.length - 1];
51+
if (step && step.sourceMapSize) {
52+
return step.sourceMapSize(sm);
53+
}
54+
}
55+
parseCompileResult(stringifiedCompileResult) {
56+
let step = this.pipeline[this.pipeline.length - 1];
57+
if (step && step.parseCompileResult) {
58+
return step.parseCompileResult(stringifiedCompileResult);
59+
}
60+
}
61+
stringifyCompileResult(compileResult) {
62+
let step = this.pipeline[this.pipeline.length - 1];
63+
if (step && step.stringifyCompileResult) {
64+
return step.stringifyCompileResult(compileResult);
65+
}
66+
}
67+
compileResultSize(compileResult) {
68+
let step = this.pipeline[this.pipeline.length - 1];
69+
if (step && step.compileResultSize) {
70+
return step.compileResultSize(compileResult);
71+
}
72+
}
73+
addCompileResult(inputFile, compileResult) {
74+
for(let step of this.pipeline) {
75+
if (step.addCompileResult) {
76+
step.addCompileResult(compileResult);
77+
}
78+
}
79+
}
80+
getCacheKey(inputFile) {
81+
let step = this.pipeline[this.pipeline.length - 1];
82+
if (step && step.getCacheKey) {
83+
return step.getCacheKey(inputFile);
84+
}
85+
}
86+
getAbsoluteImportPath(inputFile) {
87+
let step = this.pipeline[this.pipeline.length - 1];
88+
if (step && step.getAbsoluteImportPath) {
89+
return step.getAbsoluteImportPath(inputFile);
90+
}
91+
}
92+
push(Compiler) {
93+
this.pipeline.push(new Compiler());
94+
}
95+
};

0 commit comments

Comments
 (0)