From b3606087b9f797e943c19aab06cf92c46fe2ea3f Mon Sep 17 00:00:00 2001 From: Shaunak Kishore Date: Wed, 23 Sep 2015 23:36:16 -0400 Subject: [PATCH] ES2015 for assert and persistence utilities --- lib/assert.js | 2 +- server/backup.js | 22 ---------------------- server/persistence.js | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 server/backup.js create mode 100644 server/persistence.js diff --git a/lib/assert.js b/lib/assert.js index 57754855..87fc2d19 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -1,6 +1,6 @@ "use strict"; -this.assert = function(condition, message) { +this.assert = (condition, message) => { if (!condition) { console.error(message); throw new Error; diff --git a/server/backup.js b/server/backup.js deleted file mode 100644 index f05c96e7..00000000 --- a/server/backup.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -var child_process = Npm.require('child_process'); -var path = Npm.require('path'); - -function get_backup_path() { - return path.join(process.env.PWD, 'server', 'backup'); -} - -Meteor.methods({ - backup: function() { - var path = get_backup_path(); - child_process.spawn('mongodump', ['--port', '3001', '--out', path]); - }, - restore: function() { - var path = get_backup_path(); - child_process.spawn('mongorestore', ['--port', '3001', '--drop', path]); - }, - wipe: function() { - base.collection.remove({}); - }, -}); diff --git a/server/persistence.js b/server/persistence.js new file mode 100644 index 00000000..b3127ba3 --- /dev/null +++ b/server/persistence.js @@ -0,0 +1,17 @@ +"use strict"; + +const child_process = Npm.require('child_process'); +const path = Npm.require('path'); + +const get_backup_path = () => path.join(process.env.PWD, 'server', 'backup'); + +Meteor.methods({ + backup() { + const path = get_backup_path(); + child_process.spawn('mongodump', ['--port', '3001', '--out', path]); + }, + restore() { + const path = get_backup_path(); + child_process.spawn('mongorestore', ['--port', '3001', '--drop', path]); + }, +});