Преглед изворни кода

Transpile with Babel to ES5 (#16)

Alasdair Smith пре 5 година
родитељ
комит
f1ed04cc58

+ 1 - 0
libraries/o-error/.gitignore

@@ -1,3 +1,4 @@
+dist
 .nyc_output
 coverage
 node_modules/

+ 7 - 0
libraries/o-error/babel.config.json

@@ -0,0 +1,7 @@
+{
+  "presets": [
+    ["@babel/env", {
+      "targets": ["last 1 year", "ie 11", "firefox esr"]
+    }]
+  ]
+}

+ 0 - 83
libraries/o-error/index.d.ts

@@ -1,83 +0,0 @@
-export = OError;
-/**
- * Light-weight helpers for handling JavaScript Errors in node.js and the
- * browser.
- */
-declare class OError extends Error {
-    /**
-     * @param {string} message as for built-in Error
-     * @param {Object} [info] extra data to attach to the error
-     * @param {Error} [cause] the internal error that caused this error
-     */
-    constructor(message: string, info?: any, cause?: Error);
-    info: any;
-    cause: Error;
-    /** @private @type {Array<TaggedError> | undefined} */
-    private _oErrorTags;
-    /**
-     * Set the extra info object for this error.
-     *
-     * @param {Object} info extra data to attach to the error
-     * @return {this}
-     */
-    withInfo(info: any): OError;
-    /**
-     * Wrap the given error, which caused this error.
-     *
-     * @param {Error} cause the internal error that caused this error
-     * @return {this}
-     */
-    withCause(cause: Error): OError;
-}
-declare namespace OError {
-    /**
-     * Tag debugging information onto any error (whether an OError or not) and
-     * return it.
-     *
-     * @example <caption>An error in a callback</caption>
-     * function findUser(name, callback) {
-     *   fs.readFile('/etc/passwd', (err, data) => {
-     *     if (err) return callback(OError.tag(err, 'failed to read passwd'))
-     *     // ...
-     *   })
-     * }
-     *
-     * @example <caption>A possible error in a callback</caption>
-     * function cleanup(callback) {
-     *   fs.unlink('/tmp/scratch', (err) => callback(err && OError.tag(err)))
-     * }
-     *
-     * @example <caption>An error with async/await</caption>
-     * async function cleanup() {
-     *   try {
-     *     await fs.promises.unlink('/tmp/scratch')
-     *   } catch (err) {
-     *     throw OError.tag(err, 'failed to remove scratch file')
-     *   }
-     * }
-     *
-     * @param {Error} error the error to tag
-     * @param {string} [message] message with which to tag `error`
-     * @param {Object} [info] extra data with wich to tag `error`
-     * @return {Error} the modified `error` argument
-     */
-    export function tag(error: Error, message?: string, info?: any): Error;
-    /**
-     * The merged info from any `tag`s and causes on the given error.
-     *
-     * If an info property is repeated, the last one wins.
-     *
-     * @param {Error | null | undefined} error any error (may or may not be an `OError`)
-     * @return {Object}
-     */
-    export function getFullInfo(error: Error): any;
-    /**
-     * Return the `stack` property from `error`, including the `stack`s for any
-     * tagged errors added with `OError.tag` and for any `cause`s.
-     *
-     * @param {Error | null | undefined} error any error (may or may not be an `OError`)
-     * @return {string}
-     */
-    export function getFullStack(error: Error): string;
-    export const maxTags: Number;
-}

Разлика између датотеке није приказан због своје велике величине
+ 1145 - 153
libraries/o-error/package-lock.json


+ 12 - 6
libraries/o-error/package.json

@@ -12,15 +12,18 @@
     "cause",
     "verror"
   ],
-  "main": "index.js",
+  "main": "dist/index.js",
   "files": [
-    "index.js",
-    "index.d.ts"
+    "dist/index.js",
+    "dist/index.d.ts"
   ],
+  "types": "dist/index.d.ts",
   "scripts": {
-    "build": "npm run --silent typecheck && npm run --silent test && npm run --silent declaration:build && npm run --silent update-readme",
-    "declaration:build": "rm -f index.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --moduleResolution node --target ES6 index.js",
-    "declaration:check": "git diff --exit-code -- index.d.ts",
+    "clean": "rm -rf dist",
+    "build": "npm run --silent clean && npm run --silent typecheck && npm run --silent test && npm run --silent build:compile && npm run --silent declaration:build && npm run --silent update-readme",
+    "build:compile": "babel index.js --out-dir dist",
+    "declaration:build": "rm -f dist/index.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --outDir dist --moduleResolution node --target ES6 index.js",
+    "declaration:check": "git diff --exit-code -- dist/index.d.ts",
     "lint": "eslint .",
     "prepublishOnly": "npm run --silent declaration:build && npm run --silent declaration:check",
     "test": "mocha",
@@ -32,6 +35,9 @@
   "license": "MIT",
   "repository": "github:overleaf/o-error",
   "devDependencies": {
+    "@babel/cli": "^7.12.10",
+    "@babel/core": "^7.12.10",
+    "@babel/preset-env": "^7.12.11",
     "@types/chai": "^4.2.12",
     "@types/node": "^13.13.2",
     "chai": "^3.3.0",

Неке датотеке нису приказане због велике количине промена