Skip to content

Commit

Permalink
fixed simulation in rtc
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Alabor committed Jun 28, 2014
1 parent fb941db commit aed5d93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/cli.js
Expand Up @@ -3,6 +3,14 @@ var parser = require('./parser')
, Task = require('./model/task')
, systemAdapter = require('./systemadapter/default');


function writeSimulationMessage() {
console.log('======================================');
console.log('You are executing in simulation mode!');
console.log('No changes are written to your system.');
console.log('======================================');
}

/** Function: executeList
* Outputs a list of all scheduled tasks to the `console`.
*/
Expand Down Expand Up @@ -61,6 +69,10 @@ function executeSchedule(action, day, time) {
function executeEnable(simulate) {
var schedule = new Schedule();

if(simulate) {
writeSimulationMessage();
}

schedule.load()
.then(systemAdapter.enable.bind(systemAdapter, schedule, simulate))
.then(schedule.save.bind(schedule))
Expand All @@ -75,6 +87,10 @@ function executeEnable(simulate) {
function executeDisable(simulate) {
var schedule = new Schedule();

if(simulate) {
writeSimulationMessage();
}

schedule.load()
.then(systemAdapter.disable.bind(systemAdapter, simulate))
.then(schedule.save.bind(schedule))
Expand Down
2 changes: 1 addition & 1 deletion lib/tooladapter/rtc.js
Expand Up @@ -19,7 +19,7 @@ function register(task, simulate) {
if(task.action === Task.START) {
var timestamp = moment(task.date).unix();

if(!simuate) {
if(!simulate) {
return q.nfcall(fs.writeFile, rtcFile, timestamp, {
encoding: 'utf-8'
});
Expand Down

0 comments on commit aed5d93

Please sign in to comment.