Authored by htoooth

fix

... ... @@ -364,7 +364,6 @@ const profile_controller = {
const column = ctx.query.column;
const result = await sourceMap(fileUrl, line, column).catch(console.log);
console.log(result)
ctx.body = {
file: result.sourcesContent,
source: result.source,
... ...
// 查找sourcemap
const request = require('superagent');
const sourceMap = require('source-map');
const config = require('../../../config/config');
const url = require('url');
const path = require('path');
const fs = require('fs');
const sourcesPathMap = {};
async function readFile(url) {
const filePath = path.join(config.sourceMap, url + '.map');
return new Promise(function(resolve, reject) {
fs.readFile(filePath, function(err, data) {
if (err) {
reject(err);
return;
}
resolve(data);
})
});
}
function fixPath(filepath) {
return filepath.replace(/\.[\.\/]+/g, "");
}
... ... @@ -17,11 +34,7 @@ async function lookupSourceMap(fileUrl, line, column) {
}
const urlPath = url.parse(fileUrl).pathname;
const {body: content} = await request.get(`${config.sourceMap.domain}/api/sourcemap/load`)
.responseType('blob')
.query({path: urlPath});
const {body: content} = await readFile(urlPath);
const fileContent = content.toString();
const fileObj = JSON.parse(fileContent);
const sources = fileObj.sources;
... ...
... ... @@ -76,9 +76,7 @@ const defaults = {
// redis key prefix
singleBrandKeyPre: 'golobal:yoho:single_brand:', // key: 品牌id, val: 名牌名
singleSortKeyPre: 'golobal:yoho:single_sort:', // key: 品类id, val: 品类名
sourceMap: {
domain: 'http://static-ci.yoho.cn'
},
sourceMap: '/home/yoho-node-ci/dist/'
};
const specific = {
... ...