diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/prebuild.yml b/.github/workflows/prebuild.yml index ad6fabc..9e85b51 100644 --- a/.github/workflows/prebuild.yml +++ b/.github/workflows/prebuild.yml @@ -6,74 +6,74 @@ jobs: strategy: matrix: include: - - os: ubuntu-22.04 - platform: linux - arch: x64 - - os: ubuntu-22.04-arm64 - platform: linux - arch: arm64 - - os: ubuntu-22.04 - platform: android - arch: x64 - - os: ubuntu-22.04 - platform: android - arch: ia32 - - os: ubuntu-22.04 - platform: android - arch: arm64 - - os: ubuntu-22.04 - platform: android - arch: arm - - os: macos-14 - platform: darwin - arch: x64 - - os: macos-14 - platform: darwin - arch: arm64 - - os: macos-14 - platform: ios - arch: arm64 - - os: macos-14 - platform: ios - arch: arm64 - tags: -simulator - flags: --simulator - - os: macos-14 - platform: ios - arch: x64 - tags: -simulator - flags: --simulator - - os: windows-2022 - platform: win32 - arch: x64 - - os: windows-2022 - platform: win32 - arch: arm64 + - os: ubuntu-22.04 + platform: linux + arch: x64 + - os: ubuntu-22.04-arm64 + platform: linux + arch: arm64 + - os: ubuntu-22.04 + platform: android + arch: x64 + - os: ubuntu-22.04 + platform: android + arch: ia32 + - os: ubuntu-22.04 + platform: android + arch: arm64 + - os: ubuntu-22.04 + platform: android + arch: arm + - os: macos-14 + platform: darwin + arch: x64 + - os: macos-14 + platform: darwin + arch: arm64 + - os: macos-14 + platform: ios + arch: arm64 + - os: macos-14 + platform: ios + arch: arm64 + tags: -simulator + flags: --simulator + - os: macos-14 + platform: ios + arch: x64 + tags: -simulator + flags: --simulator + - os: windows-2022 + platform: win32 + arch: x64 + - os: windows-2022 + platform: win32 + arch: arm64 runs-on: ${{ matrix.os }} name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - run: npm install -g bare-runtime bare-make - - run: npm install - - run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} ${{ matrix.flags }} - - run: bare-make build - - run: bare-make install - - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }} - path: prebuilds/* + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - run: npm install -g bare-runtime bare-make + - run: npm install + - run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} ${{ matrix.flags }} + - run: bare-make build + - run: bare-make install + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }} + path: prebuilds/* merge: runs-on: ubuntu-latest needs: prebuild steps: - - uses: actions/download-artifact@v4 - with: - path: prebuilds - merge-multiple: true - - uses: actions/upload-artifact@v4 - with: - name: prebuilds - path: prebuilds + - uses: actions/download-artifact@v4 + with: + path: prebuilds + merge-multiple: true + - uses: actions/upload-artifact@v4 + with: + name: prebuilds + path: prebuilds diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb82702..27db340 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,25 +11,25 @@ jobs: strategy: matrix: include: - - os: ubuntu-latest - platform: linux - arch: x64 - - os: macos-latest - platform: darwin - arch: arm64 - - os: windows-latest - platform: win32 - arch: x64 + - os: ubuntu-latest + platform: linux + arch: x64 + - os: macos-latest + platform: darwin + arch: arm64 + - os: windows-latest + platform: win32 + arch: x64 runs-on: ${{ matrix.os }} name: ${{ matrix.platform }}-${{ matrix.arch }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - run: npm install -g bare-runtime bare-make - - run: npm install - - run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} --debug - - run: bare-make build - - run: bare-make install - - run: npm test + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - run: npm install -g bare-runtime bare-make + - run: npm install + - run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} --debug + - run: bare-make build + - run: bare-make install + - run: npm test diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c18a05d --- /dev/null +++ b/.prettierrc @@ -0,0 +1 @@ +"prettier-config-standard" diff --git a/README.md b/README.md index ce9b70f..5976fd5 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Options include: filename: '', offset: 0 } -```` +``` ## License diff --git a/index.js b/index.js index f690b52..27b44af 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,11 @@ const binding = require('./binding') const errors = require('./lib/errors') module.exports = class Realm { - constructor () { + constructor() { this._handle = binding.create() } - destroy () { + destroy() { if (this._handle === null) return binding.destroy(this._handle) @@ -14,13 +14,10 @@ module.exports = class Realm { this._handle = null } - evaluate (code, opts = {}) { + evaluate(code, opts = {}) { if (this._handle === null) throw errors.REALM_DESTROYED() - const { - filename = '', - offset = 0 - } = opts + const { filename = '', offset = 0 } = opts return binding.evaluate(this._handle, code, filename, offset) } diff --git a/lib/errors.js b/lib/errors.js index fdf6e0d..3c55d3c 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,5 +1,5 @@ module.exports = class RealmError extends Error { - constructor (msg, code, fn = RealmError) { + constructor(msg, code, fn = RealmError) { super(`${code}: ${msg}`) this.code = code @@ -8,11 +8,11 @@ module.exports = class RealmError extends Error { } } - get name () { + get name() { return 'RealmError' } - static REALM_DESTROYED (msg = 'Realm has been destroyed') { + static REALM_DESTROYED(msg = 'Realm has been destroyed') { return new RealmError(msg, 'REALM_DESTROYED', RealmError.REALM_DESTROYED) } } diff --git a/package.json b/package.json index deffffb..7f12d0d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ ], "addon": true, "scripts": { - "test": "standard && bare test.js" + "test": "prettier . --check && bare test.js" }, "repository": { "type": "git", @@ -35,6 +35,7 @@ "devDependencies": { "brittle": "^3.3.2", "cmake-bare": "^1.1.7", - "standard": "^17.0.0" + "prettier": "^3.4.1", + "prettier-config-standard": "^7.0.0" } }