'use strict';

var fs = require('fs');

// Temp store while I'm goofin' around
var store = {};
try {
    store = require('../.store');
} catch (e) {}

function exitHandler(options, err) {
    if (options.cleanup) {
        fs.writeFileSync('.store.json', JSON.stringify(store));
    }
    if (err) {
        console.log(err.stack);
    }
    if (options.exit) {
        process.exit();
    }
}
process.on('exit', exitHandler.bind(null, {
    cleanup: true
}));

process.on('SIGINT', exitHandler.bind(null, {
    exit: true
}));


module.exports = store;

@@ -522,16 +522,84 @@
 e%0A%7D));%0A%0A
+process.on('SIGTERM', exitHandler.bind(null, %7B%0A    exit: true%0A%7D));%0A%0A
 %0Amodule.

handle SIGTERM as well