Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
7b2d4ba119 | |||
1a4e732fd5 | |||
3a039c935f | |||
ac5b0b8b41 | |||
3f85c9cf7d | |||
1eff60e7dd |
40
.github/workflows/build.yaml
vendored
40
.github/workflows/build.yaml
vendored
@ -37,11 +37,15 @@ jobs:
|
||||
key: node_modules
|
||||
pattern: node_modules
|
||||
|
||||
- name: Cache Artifacts
|
||||
uses: ztimson/actions/cache@develop
|
||||
- name: Upload to Registry
|
||||
uses: ztimson/actions/npm/publish@develop
|
||||
|
||||
- name: Upload to NPM
|
||||
uses: ztimson/actions/npm/publish@develop
|
||||
with:
|
||||
key: dist
|
||||
pattern: dist
|
||||
owner: ztimson
|
||||
registry: https://registry.npmjs.org/
|
||||
token: ${{secrets.NPM_TOKEN}}
|
||||
tag:
|
||||
name: Tag Version
|
||||
needs: build
|
||||
@ -59,31 +63,3 @@ jobs:
|
||||
uses: ztimson/actions/tag@develop
|
||||
with:
|
||||
tag: ${{env.VERSION}}
|
||||
|
||||
publish:
|
||||
name: Publish
|
||||
needs: build
|
||||
if: ${{github.ref_name}} == 'release'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node
|
||||
volumes:
|
||||
- '/mnt/swarm/gitea/runner/cache:/cache'
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: ztimson/actions/clone@develop
|
||||
|
||||
- name: Restore Artifacts
|
||||
uses: ztimson/actions/cache/restore@develop
|
||||
with:
|
||||
key: dist
|
||||
|
||||
- name: Upload to Registry
|
||||
uses: ztimson/actions/npm/publish@develop
|
||||
|
||||
- name: Upload to NPM
|
||||
uses: ztimson/actions/npm/publish@develop
|
||||
with:
|
||||
owner: ztimson
|
||||
registry: https://registry.npmjs.org/
|
||||
token: ${{secrets.NPM_TOKEN}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.11.1",
|
||||
"version": "0.12.3",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
@ -14,8 +14,9 @@
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/utils.mjs",
|
||||
"require": "./dist/utils.cjs",
|
||||
"import": "./dist/utils.mjs"
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -35,6 +35,27 @@ export function deepCopy<T>(value: T): T {
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge any number of objects into the target
|
||||
*
|
||||
* @param target Destination of all properties
|
||||
* @param sources Objects that will copied into target
|
||||
* @return {any} The des
|
||||
*/
|
||||
export function deepMerge<T>(target: any, ...sources: any[]): T {
|
||||
sources.forEach(s => {
|
||||
for(const key in s) {
|
||||
if(s[key] && typeof s[key] == 'object' && !Array.isArray(s[key])) {
|
||||
if(!target[key]) target[key] = {};
|
||||
deepMerge(target[key], s[key]);
|
||||
} else {
|
||||
target[key] = s[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/set a property of an object using dot notation
|
||||
*
|
||||
|
@ -83,8 +83,8 @@ export class XHR {
|
||||
|
||||
const payload = await decode();
|
||||
if(resp.ok) return payload;
|
||||
const text = resp.statusText || (typeof payload == 'string' ? payload : null);
|
||||
throw (text ? new Error(text) : payload);
|
||||
throw Object.assign(new Error(typeof payload == 'string' ? payload : resp.statusText),
|
||||
typeof payload == 'object' ? payload : {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user