mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(package) pullout v3.0.0
This commit is contained in:
parent
3721e6ab40
commit
18080f878f
6 changed files with 18 additions and 20 deletions
|
|
@ -145,7 +145,7 @@
|
|||
"opn": "^5.1.0",
|
||||
"package-json": "^5.0.0",
|
||||
"ponse": "^3.0.0",
|
||||
"pullout": "^2.0.0",
|
||||
"pullout": "^3.0.0",
|
||||
"rendy": "^2.0.0",
|
||||
"restafary": "^5.0.0",
|
||||
"restbox": "^1.0.1",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const currify = require('currify');
|
|||
const wraptile = require('wraptile');
|
||||
const squad = require('squad');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const pullout = promisify(require('pullout'));
|
||||
const pullout = require('pullout');
|
||||
const ponse = require('ponse');
|
||||
const jonny = require('jonny');
|
||||
const jju = require('jju');
|
||||
|
|
@ -193,7 +193,7 @@ async function patch(request, response) {
|
|||
}
|
||||
|
||||
async function patchConfig({name, request, response, cache}) {
|
||||
const str = await pullout(request, 'string');
|
||||
const str = await pullout(request);
|
||||
const json = jonny.parse(str);
|
||||
|
||||
manageConfig(json);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const {
|
|||
promisify,
|
||||
} = require('util');
|
||||
|
||||
const pullout = promisify(require('pullout'));
|
||||
const pullout = require('pullout');
|
||||
const ponse = require('ponse');
|
||||
const markdown = require('markdown-it')();
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ async function onGET(request, name) {
|
|||
}
|
||||
|
||||
async function onPUT(request) {
|
||||
const data = await pullout(request, 'string');
|
||||
const data = await pullout(request);
|
||||
|
||||
return parse(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const test = require('tape');
|
||||
const {promisify} = require('es6-promisify');
|
||||
const {promisify} = require('util');
|
||||
const pullout = require('pullout');
|
||||
const request = require('request');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
|
|
@ -12,7 +12,6 @@ const markdown = require('./markdown');
|
|||
const before = require('../test/before');
|
||||
const {connect} = before;
|
||||
|
||||
const _pullout = promisify(pullout);
|
||||
const _markdown = promisify(markdown);
|
||||
|
||||
const fixtureDir = path.join(__dirname, 'fixture', 'markdown');
|
||||
|
|
@ -25,7 +24,7 @@ test('cloudcmd: markdown: error', async (t) => {
|
|||
const {port, done} = await connect();
|
||||
|
||||
const [error, data] = await tryToCatch(get, `http://localhost:${port}/api/v1/markdown/not-found`)
|
||||
const result = await _pullout(data, 'string');
|
||||
const result = await pullout(data);
|
||||
|
||||
await done();
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ test('cloudcmd: markdown: error', async (t) => {
|
|||
test('cloudcmd: markdown: relative: error', async (t) => {
|
||||
const {port, done} = await connect();
|
||||
const [e, data] = await tryToCatch(get, `http://localhost:${port}/api/v1/markdown/not-found?relative`)
|
||||
const result = await _pullout(data, 'string');
|
||||
const result = await pullout(data);
|
||||
|
||||
await done();
|
||||
t.ok(/ENOENT/.test(result), 'should not found');
|
||||
|
|
@ -47,7 +46,7 @@ test('cloudcmd: markdown: relative: error', async (t) => {
|
|||
test('cloudcmd: markdown: relative', async (t) => {
|
||||
const {port, done} = await connect();
|
||||
const data = await get(`http://localhost:${port}/api/v1/markdown/HELP.md?relative`)
|
||||
const result = await _pullout(data, 'string');
|
||||
const result = await pullout(data);
|
||||
|
||||
await done();
|
||||
|
||||
|
|
@ -68,7 +67,7 @@ test('cloudcmd: markdown: put', async (t) => {
|
|||
const putStream = mdStream
|
||||
.pipe(request.put(url));
|
||||
|
||||
const [error, result] = await tryToCatch(_pullout, putStream, 'string');
|
||||
const [error, result] = await tryToCatch(pullout, putStream);
|
||||
|
||||
await done();
|
||||
|
||||
|
|
|
|||
|
|
@ -91,12 +91,11 @@ function sendData(params, callback) {
|
|||
return onGET(params, callback);
|
||||
|
||||
case 'PUT':
|
||||
return pullout(p.request, 'string', (error, body) => {
|
||||
if (error)
|
||||
return callback(error);
|
||||
|
||||
onPUT(p.name, body, callback);
|
||||
});
|
||||
return pullout(p.request)
|
||||
.then((body) => {
|
||||
onPUT(p.name, body, callback);
|
||||
})
|
||||
.catch(callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const tryToTape = require('try-to-tape');
|
|||
const test = tryToTape(require('tape'));
|
||||
const tar = require('tar-stream');
|
||||
const gunzip = require('gunzip-maybe');
|
||||
const pullout = promisify(require('pullout'));
|
||||
const pullout = require('pullout');
|
||||
|
||||
const pathTarFixture = join(__dirname, '..', 'fixture/pack.tar.gz');
|
||||
const pathZipFixture = join(__dirname, '..', 'fixture/pack.zip');
|
||||
|
|
@ -57,7 +57,7 @@ test('cloudcmd: rest: pack: tar: get', async (t) => {
|
|||
body.pipe(gunzip()).pipe(extract);
|
||||
|
||||
const [, stream] = await once('entry', extract);
|
||||
const data = await pullout(stream, 'string');
|
||||
const data = await pullout(stream);
|
||||
const file = fs.readFileSync(__dirname + '/../fixture/pack', 'utf8');
|
||||
|
||||
t.equal(file, data, 'should pack data');
|
||||
|
|
@ -89,7 +89,7 @@ test('cloudcmd: rest: pack: tar: put: file', async (t) => {
|
|||
file.pipe(gunzip()).pipe(extract);
|
||||
|
||||
const [, stream] = await once('entry', extract);
|
||||
const data = await pullout(stream);
|
||||
const data = await pullout(stream, 'buffer');
|
||||
const result = fs.readFileSync(__dirname + '/../fixture/pack');
|
||||
|
||||
fs.unlinkSync(`${__dirname}/../${name}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue