Skip to content

Commit

Permalink
setup lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Safouen Turki committed Jan 21, 2024
1 parent e1e4c13 commit 0bb672a
Show file tree
Hide file tree
Showing 16 changed files with 579 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 20
- 18
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
yarn.lock
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

411 changes: 411 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .idea/electron-is-dev-main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
21 changes: 21 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
Check if Electron is running in development.
This package must be used from the Electron main process.
You can force development mode by setting the `ELECTRON_IS_DEV` environment variable to `1`.
@example
```
import isDev from 'electron-is-dev';
if (isDev) {
console.log('Running in development');
} else {
console.log('Running in production');
}
```
*/
declare const isDev: boolean;

export default isDev;
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

Check failure on line 1 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Do not use "use strict" directive.

Check failure on line 1 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Do not use "use strict" directive.

let isDev = false;
const { protocol, hostname } = window.location;

Check failure on line 4 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

There should be no space after '{'.

Check failure on line 4 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

There should be no space before '}'.

Check failure on line 4 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

'window' is not defined.

Check failure on line 4 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

There should be no space after '{'.

Check failure on line 4 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

There should be no space before '}'.

Check failure on line 4 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

'window' is not defined.


Check failure on line 6 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

More than 1 blank line not allowed.

Check failure on line 6 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

More than 1 blank line not allowed.

if(

Check failure on line 8 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 0 tabs but found 1.

Check failure on line 8 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected space(s) after "if".

Check failure on line 8 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 0 tabs but found 1.

Check failure on line 8 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected space(s) after "if".
(protocol === 'http:' || protocol === 'https:') ||

Check failure on line 9 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 1 tab but found 2.

Check failure on line 9 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

'||' should be placed at the beginning of the line.

Check failure on line 9 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 1 tab but found 2.

Check failure on line 9 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

'||' should be placed at the beginning of the line.
(hostname === 'localhost' || hostname.startsWith('localhost:'))

) {

Check failure on line 12 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 0 tabs but found 1.

Check failure on line 12 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 0 tabs but found 1.
isDev = true;
}

module.exports.isDev = isDev;


4 changes: 4 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {expectType} from 'tsd';
import isDev from './index.js';

expectType<boolean>(isDev);
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "electron-vite-is-dev",
"version": "0.0.1",
"description": "Check if Electron-Vite is running in development",
"license": "Apache 2.0",
"repository": "Safouene1/electron-vite-is-dev",
"author": {
"name": "Safouen Turki",
"email": "tsafouen@gmail.com",
"url": "safouen.substack.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"electron",
"dev",
"electron-vite",
"development",
"mode",
"prod",
"production",
"detect",
"check",
"debug",
"app"
],
"devDependencies": {
"tsd": "^0.30.3",
"xo": "^0.56.0"
}
}

0 comments on commit 0bb672a

Please sign in to comment.