forked from sintaxi/harp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.js
128 lines (96 loc) · 3.4 KB
/
compile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var should = require("should")
var request = require('request')
var path = require("path")
var fs = require("fs")
var exec = require("child_process").exec
var harp = require("../");
describe("compile", function(){
describe("basic app", function(){
var projectPath = path.join(__dirname, "apps/compile/basic")
var outputPath = path.join(__dirname, "out/compile-basic")
it("should compile", function(done){
harp.compile(projectPath, outputPath, function(error){
should.not.exist(error)
done()
})
})
it("compile should not include folders named with underscores", function(done) {
var cssOutputPath = path.join(outputPath, "/css")
var rsp = fs.existsSync(path.join(cssOutputPath, "/_partials/some.css"))
rsp.should.be.false
var rsp = fs.existsSync(path.join(cssOutputPath, "/_partials/_more.css"))
rsp.should.be.false
done()
})
it("compile should not include files named with underscores", function(done) {
var cssOutputPath = path.join(outputPath, "/css")
var rsp = fs.existsSync(path.join(cssOutputPath, "/one/two/three/_four.css"))
rsp.should.be.false
var rsp = fs.existsSync(path.join(cssOutputPath, "/one/two/three/_five.css"))
rsp.should.be.false
var rsp = fs.existsSync(path.join(cssOutputPath, "/_nav.css"))
rsp.should.be.false
done()
})
after(function(done){
exec("rm -rf " + outputPath, function() {
done();
})
})
})
describe("root app with .git dir", function(){
var projectPath = path.join(__dirname, "apps","compile","root")
var outputPath = path.join(__dirname, "out","compile-root")
var gitPath = path.join(projectPath, ".git")
// Make at runtime since git refuses to store .git dirs
if (!fs.existsSync(gitPath)) {
fs.mkdirSync(gitPath);
fs.openSync(path.join(gitPath, "foo"), 'a')
}
it("should compile", function(done){
harp.compile(projectPath, outputPath, function(error){
should.not.exist(error)
done()
})
})
it("should not include .git in output", function(done) {
var rsp = fs.existsSync(path.join(projectPath, ".git", "foo"))
rsp.should.be.true
var rsp = fs.existsSync(path.join(outputPath, ".git"))
rsp.should.be.false
done()
})
after(function(done){
exec("rm -rf " + outputPath + " " + gitPath, function() {
done();
})
})
})
describe("root app with output dir containing .git in project dir", function(){
var projectPath = path.join(__dirname, "apps","compile","root")
var outputPath = path.join(projectPath, "out")
var gitPath = path.join(outputPath, ".git")
// Making this at runtime since git refuses to store .git dirs
if (!fs.existsSync(gitPath)) {
fs.mkdirSync(outputPath);
fs.mkdirSync(gitPath);
fs.openSync(path.join(gitPath, "foo"), 'a')
}
it("should compile", function(done){
harp.compile(projectPath, outputPath, function(error){
should.not.exist(error)
done()
})
})
it("should not include a copy of the output subpath in output", function(done) {
var rsp = fs.existsSync(path.join(outputPath, "out"))
rsp.should.be.false
done();
})
after(function(done){
exec("rm -rf " + outputPath, function() {
done();
})
})
})
})