From 807813ecdb6956c2e204ad4d406b8bfc3f5a1a90 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 19 Dec 2016 20:50:30 +0200 Subject: [PATCH] chore(validate) es2015-ify --- lib/server/validate.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/server/validate.js b/lib/server/validate.js index bc1317bd..83048bb4 100644 --- a/lib/server/validate.js +++ b/lib/server/validate.js @@ -1,38 +1,38 @@ 'use strict'; -var exit = require('./exit'); +const exit = require('./exit'); module.exports.root = root; module.exports.editor = editor; module.exports.packer = packer; function root(dir, fn) { - var fs; - if (typeof dir !== 'string') throw Error('dir should be a string'); - if (dir !== '/') { - fs = require('fs'); - fs.stat(dir, function(error) { - if (error) - return exit('cloudcmd --root: %s', error.message); - - if (typeof fn === 'function') - fn('root:', dir); - }); - } + if (dir === '/') + return; + + const fs = require('fs'); + + fs.stat(dir, (error) => { + if (error) + return exit('cloudcmd --root: %s', error.message); + + if (typeof fn === 'function') + fn('root:', dir); + }); } function editor(name) { - var reg = /^(dword|edward|deepword)$/; + const reg = /^(dword|edward|deepword)$/; if (!reg.test(name)) exit('cloudcmd --editor: could be "dword", "edward" or "deepword" only'); } function packer(name) { - var reg = /^(tar|zip)$/; + const reg = /^(tar|zip)$/; if (!reg.test(name)) exit('cloudcmd --packer: could be "tar" or "zip" only');