mirror of
https://github.com/engineer-man/piston.git
synced 2025-05-02 01:46:28 +02:00
api: lint **everything**
This commit is contained in:
parent
216451d1aa
commit
60c004eea9
22 changed files with 764 additions and 550 deletions
|
@ -1,34 +1,33 @@
|
|||
const fs = require("fs"),
|
||||
path= require("path"),
|
||||
util = require("util"),
|
||||
fetch = require("node-fetch"),
|
||||
urlp = require("url")
|
||||
const fs = require('fs/promises'),
|
||||
path= require('path'),
|
||||
fetch = require('node-fetch'),
|
||||
urlp = require('url');
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
async buffer_from_u_r_l(url){
|
||||
if(!(url instanceof URL))
|
||||
url = new URL(url)
|
||||
if(url.protocol == "file:"){
|
||||
url = new URL(url);
|
||||
if(url.protocol == 'file:'){
|
||||
//eslint-disable-next-line snakecasejs/snakecasejs
|
||||
return await util.promisify(fs.read_file)(urlp.fileURLToPath(url))
|
||||
return await fs.read_file(urlp.fileURLToPath(url));
|
||||
}else{
|
||||
return await fetch({
|
||||
url: url.toString()
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
add_url_base_if_required(url, base){
|
||||
try{
|
||||
return new URL(url)
|
||||
return new URL(url);
|
||||
}catch{
|
||||
//Assume this is a file name
|
||||
return new URL(url, base + "/")
|
||||
return new URL(url, base + '/');
|
||||
}
|
||||
},
|
||||
url_basename(url){
|
||||
return path.basename(url.pathname)
|
||||
return path.basename(url.pathname);
|
||||
},
|
||||
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue