Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use env var to specify nodes scratch folder #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# universal-localstorage

localstorage that works in node and the browser

[![Build Status](https://img.shields.io/codeship/3bfffde0-1184-0133-460e-76104088809d.svg)](https://codeship.com/projects/92304)
Expand All @@ -10,8 +11,17 @@ On node it will use [node-localstorage](https://www.npmjs.com/package/node-local
On web if localstorage is available it will use the browsers version of localstorage.
If the browser doesn't have localstorage it will use [Remy Sharp's pollyfill](https://gist.github.com/remy/350433)

### Change node's folder

By default universal-localstorage will use `./uls-scratch` as the storage folder in node.
To change the folder, set the `ULS_FOLDER` to a specified folder

```shell
ULS_FOLDER=./my_scratch_folder
```

## Testing

```shell
npm test
```
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Storage from './rem-localstorage'

let localStorage: Storage
if (typeof window === 'undefined') {
const LocalStorage = require('node-localstorage').LocalStorage
localStorage = new LocalStorage('./uls-scratch')
const { LocalStorage } = require('node-localstorage')
localStorage = new LocalStorage(process.env.ULS_FOLDER || './uls-scratch')
} else if (
typeof window.localStorage === 'undefined' ||
typeof window.sessionStorage === 'undefined'
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2016",
"target": "ES5",
"module": "UMD",
"rootDir": "./src",
"declaration": true,
Expand Down