diff --git a/index.js b/index.js index 54012b5..fa585f5 100644 --- a/index.js +++ b/index.js @@ -10,10 +10,11 @@ import { parseCookie } from './lib/cookie.js' import fs from 'iofs' import URL from 'url' import QS from 'querystring' +import PATH from 'path' -var __dirname = path.dirname(URL.fileURLToPath(import.meta.url)) +var __dirname = PATH.dirname(URL.fileURLToPath(import.meta.url)) -var tmpdir = path.resolve(__dirname, './.tmp/') +var tmpdir = PATH.resolve(__dirname, './.tmp/') var encode = encodeURIComponent var decode = decodeURIComponent @@ -40,6 +41,8 @@ export default class Request { if (fs.isdir(tmpdir)) { fs.rm(tmpdir) + } else { + fs.mkdir(tmpdir) } } diff --git a/package.json b/package.json index b0bf9ee..46474f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gm5/request", - "version": "1.2.2", + "version": "1.2.3", "description": "对Http的request进一步封装, 提供常用的API", "main": "index.js", "author": "yutent",