From 22d1c801fa4091ec2b14986c9f6a2c211fc9c7bc Mon Sep 17 00:00:00 2001 From: Thiebaud Thomas Date: Tue, 14 Mar 2017 20:57:49 +0100 Subject: [PATCH] fix(module): Add export for commonjs (#88) * fix(module): Add export for commonjs Add commonjs export, so it is possible to require crossEnv using `require('cross-env')` (needed to use in js script without babel) 84 * fix(module): Only export crossEnv using commonjs --- .all-contributorsrc | 11 +++++++++++ README.md | 5 +++-- src/bin/cross-env.js | 2 +- src/index.js | 2 +- src/index.test.js | 3 ++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 0703896..0b0e61a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -81,6 +81,17 @@ "code", "test" ] + }, + { + "login": "thomasthiebaud", + "name": "Thiebaud Thomas", + "avatar_url": "https://avatars0.githubusercontent.com/u/3715715?v=3", + "profile": "https://github.com/thomasthiebaud", + "contributions": [ + "bug", + "code", + "test" + ] } ] } diff --git a/README.md b/README.md index 474a709..d2fedad 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Run scripts that set and use environment variables across platforms [![downloads][downloads-badge]][npm-stat] [![MIT License][license-badge]][LICENSE] -[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Donate][donate-badge]][donate] [![Code of Conduct][coc-badge]][coc] @@ -102,8 +102,9 @@ much easier for windows users. Thanks goes to these people ([emoji key][emojis]): -| [
Kent C. Dodds](https://kentcdodds.com)
[πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds) [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds) πŸš‡ [⚠️](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds) | [
Ya Zhuang ](https://zhuangya.me)
πŸ”Œ [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=zhuangya) | [
James Harris](https://wopian.me)
[πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=wopian) | [
compumike08](https://github.com/compumike08)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Acompumike08) [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=compumike08) [⚠️](https://github.com/kentcdodds/cross-env/commits?author=compumike08) | [
Daniel RodrΓ­guez Rivero](https://github.com/danielo515)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Adanielo515) [πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=danielo515) [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=danielo515) | [
Jonas Keinholz](https://github.com/inyono)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Ainyono) [πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=inyono) [⚠️](https://github.com/kentcdodds/cross-env/commits?author=inyono) | [
Hugo Wood](https://github.com/hgwood/blog)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Ahgwood) [πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=hgwood) [⚠️](https://github.com/kentcdodds/cross-env/commits?author=hgwood) | +| [
Kent C. Dodds](https://kentcdodds.com)
[πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds) [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds) πŸš‡ [⚠️](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds) | [
Ya Zhuang ](https://zhuangya.me)
πŸ”Œ [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=zhuangya) | [
James Harris](https://wopian.me)
[πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=wopian) | [
compumike08](https://github.com/compumike08)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Acompumike08) [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=compumike08) [⚠️](https://github.com/kentcdodds/cross-env/commits?author=compumike08) | [
Daniel RodrΓ­guez Rivero](https://github.com/danielo515)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Adanielo515) [πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=danielo515) [πŸ“–](https://github.com/kentcdodds/cross-env/commits?author=danielo515) | [
Jonas Keinholz](https://github.com/inyono)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Ainyono) [πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=inyono) [⚠️](https://github.com/kentcdodds/cross-env/commits?author=inyono) | [
Hugo Wood](https://github.com/hgwood)
[πŸ›](https://github.com/kentcdodds/cross-env/issues?q=author%3Ahgwood) [πŸ’»](https://github.com/kentcdodds/cross-env/commits?author=hgwood) [⚠️](https://github.com/kentcdodds/cross-env/commits?author=hgwood) | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| [
Thiebaud Thomas](https://github.com/thomasthiebaud)
| This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome! diff --git a/src/bin/cross-env.js b/src/bin/cross-env.js index 1cbfda6..5ed1b7f 100644 --- a/src/bin/cross-env.js +++ b/src/bin/cross-env.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -import crossEnv from '../' +const crossEnv = require('..') crossEnv(process.argv.slice(2)) diff --git a/src/index.js b/src/index.js index 6a299ae..876ae2c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import {spawn} from 'cross-spawn' import commandConvert from './command' -export default crossEnv +module.exports = crossEnv const envSetterRegex = /(\w+)=('(.+)'|"(.+)"|(.+))/ diff --git a/src/index.test.js b/src/index.test.js index 0f0e2f3..b60d40f 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -1,5 +1,6 @@ import crossSpawnMock from 'cross-spawn' -import crossEnv from '.' + +const crossEnv = require('.') beforeEach(() => { crossSpawnMock.__mock.reset()