Skip to content

Commit

Permalink
create repo, add source, tests (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdholt authored May 6, 2018
1 parent 46656f6 commit 51e97d6
Show file tree
Hide file tree
Showing 16 changed files with 6,737 additions and 4 deletions.
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ build/Release
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

Expand All @@ -57,3 +54,12 @@ typings/
# dotenv environment variables file
.env

# Ignore distribution directory
dist/

#Ignore Mac .DS_Store
.DS_Store

#Ignore VSCode
.vscode/
.vs/
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tests
__test__/
*.spec.*
*.test.*

# Source files
src/
build/
coverage/

# Build files
.travis.yml
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "lts/*"
install:
- npm install
dist: trusty
sudo: false
script:
- npm run test
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# exenv-es6
React's ExecutionEnvironment module extracted as ES6
React's ExecutionEnvironment module extracted as ES6 functions. Based on the ExecutionEnviroment module licensed under the MIT license by Facebook, Inc

## Package exports
`canUseDOM` - Checks if the DOM is available to access and use
`canUseWorkers` - Checks if Web Workers are available for use
`canUseEventListeners` - Checks if Event Listeners are available for use
`canUseViewport` - Checks if there is a viewport available

## Usage
```
npm i exenv-es6 --save
```

```js
import { canUseDOM } from "exenv-es6";

if (canUseDOM()) {
// do something that requires the dom
}
```

_Inspired by [exenv](https://github.com/JedWatson/exenv) from [JedWatson](https://github.com/JedWatson)_
30 changes: 30 additions & 0 deletions build/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Utility for cleaning directories.
* Usage: node build/clean.js %path%
*/
const path = require("path");
const rimraf = require("rimraf");
const argv = require("yargs").argv;

/**
* All paths passed to the clean script
*/
const paths = argv._;

/**
* Function to remove a given path
*/
function cleanPath(cleanPath) {
const removePath = path.resolve(process.cwd(), cleanPath);

rimraf(removePath, () => {
console.log(removePath, "cleaned");
});
}

/**
* Clean all paths
*/
if (Array.isArray(paths)) {
paths.forEach(cleanPath);
}
Loading

0 comments on commit 51e97d6

Please sign in to comment.