mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) lib/client -> client
Move lib/client and lib/server one level upper
This commit is contained in:
parent
8326475a9f
commit
b71ec29db6
48 changed files with 286 additions and 255 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -14,9 +14,10 @@ modules/fancybox/sprite.psd
|
|||
|
||||
modules/currify/dist/currify.js
|
||||
|
||||
legacy
|
||||
lib_
|
||||
|
||||
.nyc_output
|
||||
|
||||
*.swp
|
||||
|
||||
bin_
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ app.json
|
|||
circle.yml
|
||||
|
||||
bin/release.js
|
||||
bin/legacy.js
|
||||
|
||||
legacy
|
||||
.es5
|
||||
|
||||
bin-legacy/release.js
|
||||
legacy/bin/release.js
|
||||
legacy/bin/legacy.js
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
'use strict';
|
||||
|
||||
const Info = require('../package');
|
||||
const DIR = __dirname + '/../';
|
||||
const DIR_LIB = DIR + 'lib/';
|
||||
const DIR_SERVER = DIR_LIB + 'server/';
|
||||
const DIR_SERVER = '../lib/server/';
|
||||
|
||||
const exit = require(DIR_SERVER + 'exit');
|
||||
const config = require(DIR_SERVER + 'config');
|
||||
|
|
@ -119,7 +117,7 @@ if (args.version) {
|
|||
}
|
||||
|
||||
function validateRoot(root) {
|
||||
const validate = require('../lib/server/validate');
|
||||
const validate = require(DIR_SERVER + 'validate');
|
||||
validate.root(root, console.log);
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +185,7 @@ function help() {
|
|||
|
||||
function repl() {
|
||||
console.log('REPL mode enabled (telnet localhost 1337)');
|
||||
require(DIR_LIB + '/server/repl');
|
||||
require(DIR_SERVER + 'repl');
|
||||
}
|
||||
|
||||
function checkUpdate() {
|
||||
|
|
|
|||
30
bin/legacy.js
Executable file
30
bin/legacy.js
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const dir = path.join(__dirname, '../lib/server');
|
||||
const _dir = path.join(__dirname, '../legacy/lib/server');
|
||||
|
||||
const setDir = (name) => {
|
||||
return path.join(_dir, name);
|
||||
};
|
||||
|
||||
|
||||
fs.readdirSync(dir)
|
||||
.map(fillFile)
|
||||
.map(writeFile);
|
||||
|
||||
function fillFile(name) {
|
||||
return {
|
||||
name: setDir(name),
|
||||
data: `module.exports = require(\'../../../lib_/server/${name}\');`
|
||||
}
|
||||
}
|
||||
|
||||
function writeFile({name, data}) {
|
||||
return fs.writeFileSync(name, data);
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ var Util, DOM, CloudFunc, join;
|
|||
this.PREFIX = '';
|
||||
this.PREFIX_URL = '';
|
||||
this.LIBDIR = '/lib/';
|
||||
this.LIBDIRCLIENT = '/lib/client/';
|
||||
this.LIBDIRCLIENT = '/client/';
|
||||
this.MIN_ONE_PANEL_WIDTH = 1155;
|
||||
this.HOST = location.origin ||
|
||||
location.protocol + '//' + location.host;
|
||||
93
client/cloudcmd.js
Normal file
93
client/cloudcmd.js
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
var CloudCmd;
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
CloudCmd = load;
|
||||
|
||||
function load(prefix) {
|
||||
prefix = prefix || '';
|
||||
|
||||
var modules = '/modules/';
|
||||
var client = 'client/';
|
||||
var files = [
|
||||
'common/util',
|
||||
'common/cloudfunc',
|
||||
client + 'dom',
|
||||
client + 'events',
|
||||
client + 'rest',
|
||||
client + 'load',
|
||||
client + 'notify',
|
||||
client + 'storage',
|
||||
client + 'files',
|
||||
client + 'dialog',
|
||||
'client/client',
|
||||
client + 'buffer',
|
||||
client + 'listeners',
|
||||
client + 'key',
|
||||
client + 'directory'
|
||||
];
|
||||
|
||||
var moduleFiles = [
|
||||
window.Promise ? '' : 'promise-polyfill/promise.min',
|
||||
libDir('format', 'format-io'),
|
||||
libDir('rendy'),
|
||||
libDir('exec', 'execon'),
|
||||
libDir('jonny'),
|
||||
libDist('emitify'),
|
||||
libDist('currify'),
|
||||
].filter(function(name) {
|
||||
return name;
|
||||
}).map(function(name) {
|
||||
return modules + name;
|
||||
});
|
||||
|
||||
var allFiles = moduleFiles
|
||||
.concat(files)
|
||||
.concat('/join/join')
|
||||
.map(function(name) {
|
||||
return name + '.js';
|
||||
});
|
||||
|
||||
var urlFiles = getJoinURL(allFiles);
|
||||
|
||||
createScript(prefix + urlFiles, function() {
|
||||
CloudCmd.init(prefix);
|
||||
});
|
||||
}
|
||||
|
||||
function libDir(name, dir) {
|
||||
var lib = '/lib/';
|
||||
|
||||
if (!dir)
|
||||
dir = name;
|
||||
|
||||
return dir + lib + name;
|
||||
}
|
||||
|
||||
function libDist(name) {
|
||||
return name + '/dist/' + name + '.min';
|
||||
}
|
||||
|
||||
function createScript(url, callback) {
|
||||
var script = document.createElement('script');
|
||||
|
||||
script.src = url;
|
||||
script.async = true;
|
||||
|
||||
script.addEventListener('load', function load(event) {
|
||||
callback(event);
|
||||
script.removeEventListener('load', load);
|
||||
});
|
||||
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function getJoinURL(names) {
|
||||
var prefix = '/join:';
|
||||
var url = prefix + names.join(':');
|
||||
|
||||
return url;
|
||||
}
|
||||
})();
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ var CloudCmd, Util, DOM, io;
|
|||
exec.with(Files.get, 'config-tmpl'),
|
||||
exec.with(DOM.load.parallel, [
|
||||
prefix + '/css/config.css',
|
||||
prefix + '/lib/client/input.js'
|
||||
prefix + CloudCmd.LIBDIRCLIENT + '/input.js'
|
||||
])
|
||||
];
|
||||
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
var CloudCmd;
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
CloudCmd = load;
|
||||
|
||||
function load(prefix) {
|
||||
prefix = prefix || '';
|
||||
|
||||
var urlFiles,
|
||||
modules = '/modules/',
|
||||
lib = 'lib/',
|
||||
client = 'client/',
|
||||
files = [
|
||||
'util',
|
||||
'cloudfunc',
|
||||
client + 'dom',
|
||||
client + 'events',
|
||||
client + 'rest',
|
||||
client + 'load',
|
||||
client + 'notify',
|
||||
client + 'storage',
|
||||
client + 'files',
|
||||
client + 'dialog',
|
||||
'client',
|
||||
client + 'buffer',
|
||||
client + 'listeners',
|
||||
client + 'key',
|
||||
client + 'directory'
|
||||
].map(function(name) {
|
||||
return lib + name;
|
||||
}),
|
||||
|
||||
moduleFiles = [
|
||||
window.Promise ? '' : 'promise-polyfill/promise.min',
|
||||
libDir('format', 'format-io'),
|
||||
libDir('rendy'),
|
||||
libDir('exec', 'execon'),
|
||||
libDir('jonny'),
|
||||
libDist('emitify'),
|
||||
libDist('currify'),
|
||||
].filter(function(name) {
|
||||
return name;
|
||||
}).map(function(name) {
|
||||
return modules + name;
|
||||
});
|
||||
|
||||
files = moduleFiles
|
||||
.concat(files)
|
||||
.concat('/join/join')
|
||||
.map(function(name) {
|
||||
return name + '.js';
|
||||
});
|
||||
|
||||
urlFiles = getJoinURL(files);
|
||||
|
||||
createScript(prefix + urlFiles, function() {
|
||||
CloudCmd.init(prefix);
|
||||
});
|
||||
}
|
||||
|
||||
function libDir(name, dir) {
|
||||
var lib = '/lib/';
|
||||
|
||||
if (!dir)
|
||||
dir = name;
|
||||
|
||||
return dir + lib + name;
|
||||
}
|
||||
|
||||
function libDist(name) {
|
||||
return name + '/dist/' + name + '.min';
|
||||
}
|
||||
|
||||
function createScript(url, callback) {
|
||||
var script = document.createElement('script');
|
||||
|
||||
script.src = url;
|
||||
script.async = true;
|
||||
|
||||
script.addEventListener('load', function load(event) {
|
||||
callback(event);
|
||||
script.removeEventListener('load', load);
|
||||
});
|
||||
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function getJoinURL(names) {
|
||||
var prefix = '/join:';
|
||||
var url = prefix + names.join(':');
|
||||
|
||||
return url;
|
||||
}
|
||||
})();
|
||||
|
||||
|
|
@ -3,8 +3,9 @@
|
|||
var DIR = __dirname + '/';
|
||||
var DIR_ROOT = DIR + '../';
|
||||
var DIR_SERVER = DIR + 'server/';
|
||||
var DIR_COMMON = DIR + '../common/';
|
||||
|
||||
var cloudfunc = require(DIR + 'cloudfunc');
|
||||
var cloudfunc = require(DIR_COMMON + 'cloudfunc');
|
||||
|
||||
var auth = require(DIR_SERVER + 'auth');
|
||||
var config = require(DIR_SERVER + 'config');
|
||||
|
|
@ -290,7 +291,7 @@ function setUrl(pref) {
|
|||
req.url = req.url.replace(prefix, '') || '/';
|
||||
|
||||
if (req.url === '/cloudcmd.js')
|
||||
req.url = '/lib/client/cloudcmd.js';
|
||||
req.url = '/client/cloudcmd.js';
|
||||
|
||||
next();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var DIR_LIB = './',
|
||||
DIR_SERVER = DIR_LIB + 'server/',
|
||||
DIR_SERVER = DIR_LIB + 'server/',
|
||||
|
||||
http = require('http'),
|
||||
opn = require('opn'),
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
var DIR_SERVER = __dirname + '/',
|
||||
DIR_LIB = DIR_SERVER + '../',
|
||||
DIR_COMMON = DIR_SERVER + '../../common/',
|
||||
DIR = DIR_SERVER + '../../',
|
||||
|
||||
path = require('path'),
|
||||
|
||||
exit = require(DIR_SERVER + 'exit'),
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
CloudFunc = require(DIR_COMMON + 'cloudfunc'),
|
||||
|
||||
pullout = require('pullout/legacy'),
|
||||
ponse = require('ponse'),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var DIR = './',
|
||||
DIR_LIB = '../',
|
||||
DIR_ROOT = __dirname + '/' + DIR_LIB + '../',
|
||||
DIR_ROOT = __dirname + '/../../',
|
||||
|
||||
fs = require('fs'),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
var DIR = './',
|
||||
DIR_LIB = DIR + '../',
|
||||
DIR_COMMON = DIR + '../../common/',
|
||||
|
||||
path = require('path'),
|
||||
root = require(DIR + 'root'),
|
||||
config = require(DIR + 'config'),
|
||||
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
CloudFunc = require(DIR_COMMON + 'cloudfunc'),
|
||||
|
||||
markdown = require(DIR + 'markdown'),
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
var DIR = __dirname + '/../../',
|
||||
DIR_TMPL = DIR + 'tmpl/',
|
||||
DIR_HTML = DIR + 'html/',
|
||||
DIR_LIB = DIR + 'lib/',
|
||||
DIR_COMMON = DIR + 'common/',
|
||||
DIR_JSON = DIR + 'json/',
|
||||
DIR_SERVER = __dirname + '/',
|
||||
DIR_FS = DIR_TMPL + 'fs/',
|
||||
|
|
@ -26,7 +26,7 @@ var DIR = __dirname + '/../../',
|
|||
prefixer = require(DIR_SERVER + 'prefixer'),
|
||||
prefix = squad(prefixer, apart(config, 'prefix')),
|
||||
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
CloudFunc = require(DIR_COMMON + 'cloudfunc'),
|
||||
|
||||
PATH_INDEX = DIR_HTML + 'index.html',
|
||||
|
||||
|
|
|
|||
29
package.json
29
package.json
|
|
@ -35,11 +35,11 @@
|
|||
"server"
|
||||
],
|
||||
"bin": {
|
||||
"cloudcmd": "bin_/cloudcmd.js",
|
||||
"cloudcmd": "legacy/bin/cloudcmd.js",
|
||||
"cloudcmd+": "bin/cloudcmd.js"
|
||||
},
|
||||
"config": {
|
||||
"dirs_legacy": "bin lib",
|
||||
"dirs_legacy": "client",
|
||||
"dirs": "bin lib test"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
@ -50,13 +50,13 @@
|
|||
"lint": "redrun lint:*",
|
||||
"lint:css": "recess css/*.css",
|
||||
"lint:style": "stylelint css/*.css",
|
||||
"lint:js": "redrun jshint jscs eslint",
|
||||
"lint:js:legacy": "redrun legacy:*",
|
||||
"eslint": "eslint --rule 'no-console:0' test bin/release.js",
|
||||
"lint:js": "redrun jshint jscs eslint:*",
|
||||
"lint:js:es5": "redrun es5:*",
|
||||
"eslint:bin": "eslint --rule 'no-console:0' bin test lib",
|
||||
"jshint": "jshint bin/release.js",
|
||||
"jscs": "jscs --esnext $npm_package_config_dirs",
|
||||
"legacy:jshint": "jshint --config legacy/.jshintrc $npm_package_config_dirs_dirs_legacy --exclude bin/release.js",
|
||||
"legacy:eslint": "eslint -c legacy/.eslintrc --rule 'no-console:0' $npm_package_config_dirs_legacy --ignore-path bin/release.js",
|
||||
"es5:jshint": "jshint --config .es5/.jshintrc $npm_package_config_dirs_dirs_legacy --exclude bin/release.js",
|
||||
"es5:eslint": "eslint -c .es5/.eslintrc --rule 'no-console:0' $npm_package_config_dirs_legacy --ignore-path bin/release.js",
|
||||
"test": "tape 'test/**/*.js'",
|
||||
"watch:test": "nodemon -w lib -w test -x \"npm run test\"",
|
||||
"spell": "yaspeller .",
|
||||
|
|
@ -79,8 +79,15 @@
|
|||
"docker:rm-old": "redrun --parallel docker:rm:*",
|
||||
"coverage": "nyc npm test",
|
||||
"report": "nyc report --reporter=text-lcov | coveralls",
|
||||
"6to5:bin": "babel bin -d bin_",
|
||||
"build": "redrun 6to5:*"
|
||||
"6to5:bin": "babel bin -d legacy/bin",
|
||||
"6to5:lib": "babel lib -d lib_",
|
||||
"build": "redrun rm:* 6to5:* mkdir:* legacy:*",
|
||||
"legacy:package": "echo \"module.exports = require('../package');\" > legacy/package.js",
|
||||
"legacy:lib:cloudcmd": "echo \"module.exports = require('../../lib_/cloudcmd');\" > legacy/lib/cloudcmd.js",
|
||||
"legacy:lib:server": "echo \"module.exports = require('../../lib_/server');\" > legacy/lib/server.js",
|
||||
"mkdir:server": "mkdirp legacy/lib/server",
|
||||
"legacy:server": "bin/legacy.js",
|
||||
"rm:legacy": "rimraf legacy"
|
||||
},
|
||||
"directories": {
|
||||
"man": "man"
|
||||
|
|
@ -139,6 +146,7 @@
|
|||
"jscs": "^3.0.1",
|
||||
"jshint": "^2.8.0",
|
||||
"minor": "^1.2.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"morgan": "^1.6.1",
|
||||
"nodemon": "^1.9.1",
|
||||
"nsp": "^2.2.1",
|
||||
|
|
@ -147,6 +155,7 @@
|
|||
"recess": "^1.1.9",
|
||||
"redrun": "^5.0.0",
|
||||
"request": "^2.76.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"shortdate": "^1.0.1",
|
||||
"socket.io-client": "^1.5.1",
|
||||
"stylelint": "^7.0.2",
|
||||
|
|
@ -160,5 +169,5 @@
|
|||
"node": ">=0.10"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "lib/cloudcmd.js"
|
||||
"main": "legacy/lib/cloudcmd.js"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const io = require('socket.io');
|
|||
const writejson = require('writejson');
|
||||
const readjson = require('readjson');
|
||||
|
||||
const cloudcmd = require('..');
|
||||
const cloudcmd = require('../lib/cloudcmd');
|
||||
const {assign} = Object;
|
||||
|
||||
const pathConfig = os.homedir() + '/.cloudcmd.json';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const cloudcmd = require('../..');
|
||||
const cloudcmd = require('../../lib/cloudcmd');
|
||||
|
||||
test('cloudcmd: args: no', (t) => {
|
||||
const fn = () => cloudcmd();
|
||||
|
|
|
|||
|
|
@ -1,128 +1,126 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
var DIR = __dirname + '/../../',
|
||||
COMMONDIR = DIR + 'common/',
|
||||
TMPLDIR = DIR + 'tmpl/',
|
||||
|
||||
var DIR = __dirname + '/../../',
|
||||
LIBDIR = DIR + 'lib/',
|
||||
TMPLDIR = DIR + 'tmpl/',
|
||||
|
||||
Util = require(LIBDIR + 'util'),
|
||||
CloudFunc = require(LIBDIR + 'cloudfunc'),
|
||||
files = require('files-io'),
|
||||
rendy = require('rendy'),
|
||||
|
||||
test = require('tape'),
|
||||
|
||||
FS_DIR = TMPLDIR + 'fs/',
|
||||
EXPECT_PATH = DIR + 'test/lib/cloudfunc.html',
|
||||
|
||||
TMPL_PATH = [
|
||||
'file',
|
||||
'path',
|
||||
'pathLink',
|
||||
'link',
|
||||
],
|
||||
|
||||
JSON_FILES = {
|
||||
path : '/etc/X11/',
|
||||
files : [{
|
||||
name: 'applnk',
|
||||
size: 'dir',
|
||||
date: '21.02.2016',
|
||||
uid : 0,
|
||||
mode: 'rwx r-x r-x'
|
||||
}, {
|
||||
name: 'prefdm',
|
||||
size: '1.30kb',
|
||||
date: '21.02.2016',
|
||||
uid : 0,
|
||||
mode: 'rwx r-x r-x'
|
||||
}]
|
||||
},
|
||||
|
||||
Expect =
|
||||
'<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
|
||||
'<span data-name="js-clear-storage" class="path-icon icon-clear" ' +
|
||||
'title="clear storage (Ctrl+D)">' +
|
||||
'</span>' +
|
||||
'<a data-name="js-refresh" href="/fs/etc/X11/" ' +
|
||||
'class="path-icon icon-refresh" title="refresh (Ctrl+R)"></a>' +
|
||||
'<span data-name="js-links" class=links>' +
|
||||
'<a data-name="js-path-link" href="/fs/" title="/">/</a>' +
|
||||
'<a data-name="js-path-link" href="/fs/etc/" title="/etc/">' +
|
||||
'etc' +
|
||||
'</a>/X11/' +
|
||||
'</span>' +
|
||||
'</div>';
|
||||
Util = require(COMMONDIR + 'util'),
|
||||
CloudFunc = require(COMMONDIR + 'cloudfunc'),
|
||||
files = require('files-io'),
|
||||
rendy = require('rendy'),
|
||||
|
||||
test(function(t) {
|
||||
var paths = {},
|
||||
|
||||
filesList = TMPL_PATH.map(function(name) {
|
||||
var path = FS_DIR + name + '.hbs';
|
||||
|
||||
paths[path] = name;
|
||||
|
||||
return path;
|
||||
})
|
||||
.concat(EXPECT_PATH);
|
||||
test = require('tape'),
|
||||
|
||||
FS_DIR = TMPLDIR + 'fs/',
|
||||
EXPECT_PATH = DIR + 'test/lib/cloudfunc.html',
|
||||
|
||||
TMPL_PATH = [
|
||||
'file',
|
||||
'path',
|
||||
'pathLink',
|
||||
'link',
|
||||
],
|
||||
|
||||
JSON_FILES = {
|
||||
path : '/etc/X11/',
|
||||
files : [{
|
||||
name: 'applnk',
|
||||
size: 'dir',
|
||||
date: '21.02.2016',
|
||||
uid : 0,
|
||||
mode: 'rwx r-x r-x'
|
||||
}, {
|
||||
name: 'prefdm',
|
||||
size: '1.30kb',
|
||||
date: '21.02.2016',
|
||||
uid : 0,
|
||||
mode: 'rwx r-x r-x'
|
||||
}]
|
||||
},
|
||||
|
||||
Expect =
|
||||
'<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
|
||||
'<span data-name="js-clear-storage" class="path-icon icon-clear" ' +
|
||||
'title="clear storage (Ctrl+D)">' +
|
||||
'</span>' +
|
||||
'<a data-name="js-refresh" href="/fs/etc/X11/" ' +
|
||||
'class="path-icon icon-refresh" title="refresh (Ctrl+R)"></a>' +
|
||||
'<span data-name="js-links" class=links>' +
|
||||
'<a data-name="js-path-link" href="/fs/" title="/">/</a>' +
|
||||
'<a data-name="js-path-link" href="/fs/etc/" title="/etc/">' +
|
||||
'etc' +
|
||||
'</a>/X11/' +
|
||||
'</span>' +
|
||||
'</div>';
|
||||
|
||||
test(function(t) {
|
||||
var paths = {},
|
||||
|
||||
files.read(filesList, 'utf8', function(error, files) {
|
||||
var isNotOk, expect, result,
|
||||
i = 0,
|
||||
template = {};
|
||||
filesList = TMPL_PATH.map(function(name) {
|
||||
var path = FS_DIR + name + '.hbs';
|
||||
|
||||
if (error) {
|
||||
throw(new Error(error));
|
||||
} else {
|
||||
Util.time('CloudFunc.buildFromJSON');
|
||||
paths[path] = name;
|
||||
|
||||
return path;
|
||||
})
|
||||
.concat(EXPECT_PATH);
|
||||
|
||||
files.read(filesList, 'utf8', function(error, files) {
|
||||
var isNotOk, expect, result,
|
||||
i = 0,
|
||||
template = {};
|
||||
|
||||
if (error) {
|
||||
throw(new Error(error));
|
||||
} else {
|
||||
Util.time('CloudFunc.buildFromJSON');
|
||||
|
||||
Object.keys(files).forEach(function(path) {
|
||||
var name = paths[path];
|
||||
|
||||
Object.keys(files).forEach(function(path) {
|
||||
var name = paths[path];
|
||||
|
||||
if (path !== EXPECT_PATH)
|
||||
template[name] = files[path];
|
||||
});
|
||||
if (path !== EXPECT_PATH)
|
||||
template[name] = files[path];
|
||||
});
|
||||
|
||||
expect = files[EXPECT_PATH];
|
||||
|
||||
result = CloudFunc.buildFromJSON({
|
||||
prefix : '',
|
||||
data : JSON_FILES,
|
||||
template: template
|
||||
});
|
||||
|
||||
Expect += expect;
|
||||
|
||||
isNotOk = Expect.split('').some(function(item, number) {
|
||||
var ret = result[number] !== item;
|
||||
|
||||
expect = files[EXPECT_PATH];
|
||||
if (ret)
|
||||
i = number;
|
||||
|
||||
result = CloudFunc.buildFromJSON({
|
||||
prefix : '',
|
||||
data : JSON_FILES,
|
||||
template: template
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
Util.timeEnd('CloudFunc.buildFromJSON');
|
||||
|
||||
if (isNotOk) {
|
||||
console.log(rendy([
|
||||
'Error in char number: {{ number }}',
|
||||
'Expect: {{ expect }}',
|
||||
'Result: {{ result }}'
|
||||
].join('\n'), {
|
||||
number: i,
|
||||
expect: Expect.substr(i),
|
||||
result: result.substr(i)
|
||||
}));
|
||||
|
||||
Expect += expect;
|
||||
|
||||
isNotOk = Expect.split('').some(function(item, number) {
|
||||
var ret = result[number] !== item;
|
||||
|
||||
if (ret)
|
||||
i = number;
|
||||
|
||||
return ret;
|
||||
});
|
||||
|
||||
Util.timeEnd('CloudFunc.buildFromJSON');
|
||||
|
||||
if (isNotOk) {
|
||||
console.log(rendy([
|
||||
'Error in char number: {{ number }}',
|
||||
'Expect: {{ expect }}',
|
||||
'Result: {{ result }}'
|
||||
].join('\n'), {
|
||||
number: i,
|
||||
expect: Expect.substr(i),
|
||||
result: result.substr(i)
|
||||
}));
|
||||
|
||||
console.log('buildFromJSON: Not OK');
|
||||
}
|
||||
|
||||
t.equal(Expect, result, 'should be equal rendered json data');
|
||||
|
||||
t.end();
|
||||
console.log('buildFromJSON: Not OK');
|
||||
}
|
||||
});
|
||||
|
||||
t.equal(Expect, result, 'should be equal rendered json data');
|
||||
|
||||
t.end();
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,9 @@ test('config: manage', (t) => {
|
|||
|
||||
test('config: manage: get', (t) => {
|
||||
const editor = 'deepword';
|
||||
const conf = {
|
||||
editor
|
||||
};
|
||||
|
||||
before({config: conf}, (port, after) => {
|
||||
t.equal(editor, config('editor'), 'should get config');
|
||||
before({config: {editor}}, (port, after) => {
|
||||
t.equal(config('editor'), editor, 'should get config');
|
||||
t.end();
|
||||
after();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
var test = require('tape'),
|
||||
DIR = '../../',
|
||||
Util = require(DIR + 'lib/util');
|
||||
Util = require(DIR + 'common/util');
|
||||
|
||||
|
||||
test('getExt: no extension', function(t) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue