-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.js
31 lines (29 loc) · 1.17 KB
/
run.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
var Pediff = require('./pediff'), pediff = new Pediff(), args = pediff.cli.args;
/* Make sure the script is invoked correctly */
if (args.length === 0){
pediff.echo('No task provided!', 'ERROR');
pediff.echo('Usage: casperjs run.js taskname', 'INFO');
pediff.exit(1);
}
/* Run pediff rendering suit */
pediff.init(require('./tasks/' + args.pop()));
pediff.start().each(Object.keys(pediff.config.environments), function(pd, environment){
/* Iterate through all defined viewport sizes */
var viewports = pd.config.options.viewportSize;
pd.each(viewports, function(self, viewport){
self.then(function(){ this.setViewportSize(viewport); });
self.then(function(){ this.setEnvironment(environment); });
self.then(function(){
this.viewport(viewport.width, viewport.height, function(){
this.thenOpen(this.config.environments[environment] + (this.config.path || ''), function() {
this.preExecute();
this.execute();
});
this.then(function(){
this.postExecute();
})
});
});
});
});
pediff.run();