Skip to content

Commit

Permalink
Fixes snapshot path when missing slash (#67)
Browse files Browse the repository at this point in the history
* Fixes snapshot path when missing slash

* chore: updated CI workflows
  • Loading branch information
petruki committed May 8, 2024
1 parent 4ac0986 commit 5da639f
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 7 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build-test:
name: Build & Test
name: Quality Gate
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

Expand Down Expand Up @@ -43,3 +43,24 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

test-matrix:
name: Test Matrix - Deno ${{ matrix.deno-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
deno-version: [v1.40.0, v1.43.x]
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: Setup Deno ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}

- run: deno task test
36 changes: 36 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Staging CI
run-name: Staging - Deno ${{ github.event.inputs.deno }} / ${{ github.event.inputs.os }} by @${{ github.actor }}

on:
workflow_dispatch:
inputs:
deno:
description: 'Deno version'
required: true
default: 'v1.43.x'
os:
description: 'Operating System (ubuntu-20.04, ubuntu-latest, windows-latest)'
required: true
default: 'ubuntu-latest'
deno-flag:
description: 'Deno flag (e.g. --unstable)'
required: false
default: ''

jobs:
test:
name: Test - Deno ${{ github.event.inputs.deno }} on ${{ github.event.inputs.os }}
runs-on: ${{ github.event.inputs.os }}

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ github.event.inputs.deno }}

- run: deno task test ${{ github.event.inputs.deno-flag }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ https://github.com/switcherapi/switcher-api
## Module initialization
The context properties stores all information regarding connectivity.

(*) Requires Deno 1.4x or higher

> Flags required
```
--allow-read
--allow-write
--allow-net
--unstable (only if using certPath)
```

> Initialization
Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@switcherapi/switcher-client-deno",
"version": "1.1.0",
"version": "1.1.1",
"description": "Switcher4Deno is a Feature Flag Deno SDK client for Switcher API",
"tasks": {
"cache-reload": "deno cache --reload --lock=deno.lock --lock-write mod.ts",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.projectKey=switcherapi_switcher-client-deno
sonar.projectName=switcher-client-deno
sonar.organization=switcherapi
sonar.projectVersion=1.1.0
sonar.projectVersion=1.1.1

sonar.javascript.lcov.reportPaths=coverage/report.lcov

Expand Down
2 changes: 1 addition & 1 deletion src/lib/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const loadDomain = (snapshotLocation: string, environment: string) => {
let dataJSON;
try {
let dataBuffer;
const snapshotFile = `${snapshotLocation}${environment}.json`;
const snapshotFile = `${snapshotLocation}/${environment}.json`;
if (existsSync(snapshotFile)) {
dataBuffer = Deno.readTextFileSync(snapshotFile);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/switcher-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Switcher {
if (snapshot) {
if (Switcher._options.snapshotLocation?.length) {
Deno.writeTextFileSync(
`${Switcher._options.snapshotLocation}${Switcher._context.environment}.json`,
`${Switcher._options.snapshotLocation}/${Switcher._context.environment}.json`,
snapshot,
);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ export class Switcher {
return error(new Error('Watch Snapshot cannot be used in test mode or without a snapshot location'));
}

const snapshotFile = `${Switcher._options.snapshotLocation}${Switcher._context.environment}.json`;
const snapshotFile = `${Switcher._options.snapshotLocation}/${Switcher._context.environment}.json`;
Switcher._watcher = Deno.watchFs(snapshotFile);
Switcher._watching = true;
for await (const event of Switcher._watcher) {
Expand Down

0 comments on commit 5da639f

Please sign in to comment.