diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f371c7d..8013ada 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,12 +30,3 @@ jobs: run: npm publish --provenance --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Create release tag on GitHub - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ github.ref_name }} - run: | - gh release create "$TAG" \ - --repo="$GITHUB_REPOSITORY" \ - --title="${GITHUB_REPOSITORY#*/} ${TAG#v}" \ - --generate-notes diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index f0e4382..68d0b5d 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -35,18 +35,27 @@ jobs: cache: npm - name: Install dependencies run: npm ci - - name: Bump version - id: bump_version - uses: phips28/gh-action-bump-version@v9 + - name: Configure git identity + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + - name: Bump version with NPM version env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - version-type: ${{ github.event.inputs.type }} - default: ${{ github.event.inputs.beta == true && 'prerelease' || 'patch' }} - commit-message: "chore(release): prepare release {{version}}" - tag-prefix: "v" - skip-tag: true - skip-push: true + id: bump-version + run: | + TYPE=${{ github.event.inputs.type }} + BETA=${{ github.event.inputs.beta }} + if [ "$TYPE" = "auto" ]; then + npm version $(npm version | grep -Eo 'patch|minor|major' | head -1) + else + if [ "$BETA" = "true" ]; then + npm version $TYPE --preid=beta + else + npm version $TYPE + fi + fi + echo "::set-output name=newTag::$(node -p "require('./package.json').version")" - name: Build project run: npm run build - name: Run unit tests @@ -56,14 +65,12 @@ jobs: - name: Run browser tests run: npm run test:browser - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 + uses: peter-evans/create-pull-request@v8 with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "chore(release): prepare release ${{ steps.bump_version.outputs.newTag }}" - branch: "release/${{ steps.bump_version.outputs.newTag }}" - title: "chore(release): prepare release ${{ steps.bump_version.outputs.newTag }}" - body: "This PR prepares the release ${{ steps.bump_version.outputs.newTag }}." - base: main + branch: "release" + commit-message: "chore(release): prepare release ${{ steps.bump-version.outputs.newTag }}" + body: "This PR prepares the release ${{ steps.bump-version.outputs.newTag }}." + title: "chore(release): prepare release ${{ steps.bump-version.outputs.newTag }}" maintainer-can-modify: true draft: false labels: | diff --git a/.github/workflows/update-sponsor-block.yml b/.github/workflows/update-sponsor-block.yml index 827acc3..4cb26ec 100644 --- a/.github/workflows/update-sponsor-block.yml +++ b/.github/workflows/update-sponsor-block.yml @@ -46,7 +46,7 @@ jobs: echo "$CONTENT" if: steps.sponsors-requires-update.outputs.changed == 'true' - name: Create pull request - uses: peter-evans/create-pull-request@v7 + uses: peter-evans/create-pull-request@v8 with: branch: sponsors delete-branch: true diff --git a/lib/core/Axios.js b/lib/core/Axios.js index ec301f9..0222e73 100644 --- a/lib/core/Axios.js +++ b/lib/core/Axios.js @@ -159,13 +159,8 @@ class Axios { promise = Promise.resolve(config); - let prevResult = config; while (i < len) { - promise = promise - .then(chain[i++]) - .then(result => { prevResult = result !== undefined ? result : prevResult }) - .catch(chain[i++]) - .then(() => prevResult); + promise = promise.then(chain[i++], chain[i++]); } return promise; @@ -196,7 +191,7 @@ class Axios { len = responseInterceptorChain.length; while (i < len) { - promise = promise.then(responseInterceptorChain[i++]).catch(responseInterceptorChain[i++]); + promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]); } return promise; diff --git a/test/specs/interceptors.spec.js b/test/specs/interceptors.spec.js index ca89712..d08bcba 100644 --- a/test/specs/interceptors.spec.js +++ b/test/specs/interceptors.spec.js @@ -599,77 +599,4 @@ describe('interceptors', function () { expect(instance.interceptors.response.handlers.length).toBe(0); }); - - it('should handler the error in the same request interceptors', function (done) { - const rejectedSpy1 = jasmine.createSpy('rejectedSpy1'); - const rejectedSpy2 = jasmine.createSpy('rejectedSpy2'); - const error1 = new Error('deadly error 1'); - const error2 = new Error('deadly error 2'); - axios.interceptors.request.use(function () { - throw error1; - }, rejectedSpy1); - - axios.interceptors.request.use(function () { - throw error2; - }, rejectedSpy2); - - axios('/foo').catch(); - - getAjaxRequest().then(function () { - expect(rejectedSpy1).toHaveBeenCalledWith(error1); - expect(rejectedSpy2).toHaveBeenCalledWith(error2); - done(); - }); - }); - - it('should handle the error in the same response interceptors', function (done) { - const rejectedSpy1 = jasmine.createSpy('rejectedSpy1'); - const rejectedSpy2 = jasmine.createSpy('rejectedSpy2'); - const error1 = new Error('deadly error 1'); - const error2 = new Error('deadly error 2'); - axios.interceptors.response.use(function () { - throw error1; - }, rejectedSpy1); - - axios.interceptors.response.use(function () { - throw error2; - }, rejectedSpy2); - - axios('/foo'); - - getAjaxRequest().then(function (request) { - request.respondWith({ - status: 200, - responseText: 'OK' - }); - - setTimeout(function () { - expect(rejectedSpy1).toHaveBeenCalledWith(error1); - expect(rejectedSpy2).toHaveBeenCalledWith(error2); - done(); - }, 100); - }); - }); - - it('should skip the modification of config in the interceptors throwing error', function (done) { - const rejectedSpy = jasmine.createSpy('rejectedSpy'); - const error = new Error('deadly error'); - - axios.interceptors.request.use(function (config) { - config.headers.test = 'added by interceptor'; - return config; - }); - - axios.interceptors.request.use(function () { - throw error; - }, rejectedSpy); - - axios('/foo').catch(); - - getAjaxRequest().then(function (request) { - expect(rejectedSpy).toHaveBeenCalledWith(error); - expect(request.requestHeaders.test).toBe('added by interceptor'); - done(); - }); - }); });