Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
fix: regex flag fix (#161)
Browse files Browse the repository at this point in the history
* Adding myself as a contributor

* Using regex literal instead of constructor function

closes #159
closes #160
  • Loading branch information
NicoZelaya authored and Kent C. Dodds committed Dec 21, 2017
1 parent 7fa5c08 commit 3cf4170
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@
"example",
"test"
]
},
{
"login": "NicoZelaya",
"name": "D. Nicol谩s Lopez Zelaya",
"avatar_url": "https://avatars0.githubusercontent.com/u/5522668?v=4",
"profile": "https://github.com/NicoZelaya",
"contributions": [
"code"
]
}
]
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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-14-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]
[![Donate][donate-badge]][donate]
[![Code of Conduct][coc-badge]][coc]
Expand Down Expand Up @@ -153,9 +153,11 @@ much easier for Windows users.
Thanks goes to these people ([emoji key][emojis]):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds "Code") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds "Documentation") [馃殗](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds "Tests") | [<img src="https://avatars1.githubusercontent.com/u/499038?v=3" width="100px;"/><br /><sub>Ya Zhuang </sub>](https://zhuangya.me)<br />[馃攲](#plugin-zhuangya "Plugin/utility libraries") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=zhuangya "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/3440094?v=3" width="100px;"/><br /><sub>James Harris</sub>](https://wopian.me)<br />[馃摉](https://github.com/kentcdodds/cross-env/commits?author=wopian "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/8941730?v=3" width="100px;"/><br /><sub>compumike08</sub>](https://github.com/compumike08)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Acompumike08 "Bug reports") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=compumike08 "Documentation") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=compumike08 "Tests") | [<img src="https://avatars1.githubusercontent.com/u/2270425?v=3" width="100px;"/><br /><sub>Daniel Rodr铆guez Rivero</sub>](https://github.com/danielo515)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Adanielo515 "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=danielo515 "Code") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=danielo515 "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1508477?v=3" width="100px;"/><br /><sub>Jonas Keinholz</sub>](https://github.com/inyono)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Ainyono "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=inyono "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=inyono "Tests") | [<img src="https://avatars3.githubusercontent.com/u/1656170?v=3" width="100px;"/><br /><sub>Hugo Wood</sub>](https://github.com/hgwood)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Ahgwood "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=hgwood "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=hgwood "Tests") |
<!-- prettier-ignore -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds "Code") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds "Documentation") [馃殗](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=kentcdodds "Tests") | [<img src="https://avatars1.githubusercontent.com/u/499038?v=3" width="100px;"/><br /><sub><b>Ya Zhuang </b></sub>](https://zhuangya.me)<br />[馃攲](#plugin-zhuangya "Plugin/utility libraries") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=zhuangya "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/3440094?v=3" width="100px;"/><br /><sub><b>James Harris</b></sub>](https://wopian.me)<br />[馃摉](https://github.com/kentcdodds/cross-env/commits?author=wopian "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/8941730?v=3" width="100px;"/><br /><sub><b>compumike08</b></sub>](https://github.com/compumike08)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Acompumike08 "Bug reports") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=compumike08 "Documentation") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=compumike08 "Tests") | [<img src="https://avatars1.githubusercontent.com/u/2270425?v=3" width="100px;"/><br /><sub><b>Daniel Rodr铆guez Rivero</b></sub>](https://github.com/danielo515)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Adanielo515 "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=danielo515 "Code") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=danielo515 "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1508477?v=3" width="100px;"/><br /><sub><b>Jonas Keinholz</b></sub>](https://github.com/inyono)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Ainyono "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=inyono "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=inyono "Tests") | [<img src="https://avatars3.githubusercontent.com/u/1656170?v=3" width="100px;"/><br /><sub><b>Hugo Wood</b></sub>](https://github.com/hgwood)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Ahgwood "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=hgwood "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=hgwood "Tests") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars0.githubusercontent.com/u/3715715?v=3" width="100px;"/><br /><sub>Thiebaud Thomas</sub>](https://github.com/thomasthiebaud)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Athomasthiebaud "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=thomasthiebaud "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=thomasthiebaud "Tests") | [<img src="https://avatars1.githubusercontent.com/u/1715800?v=3" width="100px;"/><br /><sub>Daniel Rey L贸pez</sub>](https://daniel.blog)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=DanReyLop "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=DanReyLop "Tests") | [<img src="https://avatars2.githubusercontent.com/u/6374832?v=3" width="100px;"/><br /><sub>Amila Welihinda</sub>](http://amilajack.com)<br />[馃殗](#infra-amilajack "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars1.githubusercontent.com/u/1396?v=3" width="100px;"/><br /><sub>Paul Betts</sub>](https://twitter.com/paulcbetts)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Apaulcbetts "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=paulcbetts "Code") | [<img src="https://avatars1.githubusercontent.com/u/6371670?v=3" width="100px;"/><br /><sub>Turner Hayes</sub>](https://github.com/turnerhayes)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Aturnerhayes "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=turnerhayes "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=turnerhayes "Tests") | [<img src="https://avatars2.githubusercontent.com/u/22251956?v=4" width="100px;"/><br /><sub>Suhas Karanth</sub>](https://github.com/sudo-suhas)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=sudo-suhas "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=sudo-suhas "Tests") | [<img src="https://avatars3.githubusercontent.com/u/512692?v=4" width="100px;"/><br /><sub>Sven</sub>](https://github.com/sventschui)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=sventschui "Code") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=sventschui "Documentation") [馃挕](#example-sventschui "Examples") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=sventschui "Tests") |
| [<img src="https://avatars0.githubusercontent.com/u/3715715?v=3" width="100px;"/><br /><sub><b>Thiebaud Thomas</b></sub>](https://github.com/thomasthiebaud)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Athomasthiebaud "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=thomasthiebaud "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=thomasthiebaud "Tests") | [<img src="https://avatars1.githubusercontent.com/u/1715800?v=3" width="100px;"/><br /><sub><b>Daniel Rey L贸pez</b></sub>](https://daniel.blog)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=DanReyLop "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=DanReyLop "Tests") | [<img src="https://avatars2.githubusercontent.com/u/6374832?v=3" width="100px;"/><br /><sub><b>Amila Welihinda</b></sub>](http://amilajack.com)<br />[馃殗](#infra-amilajack "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars1.githubusercontent.com/u/1396?v=3" width="100px;"/><br /><sub><b>Paul Betts</b></sub>](https://twitter.com/paulcbetts)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Apaulcbetts "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=paulcbetts "Code") | [<img src="https://avatars1.githubusercontent.com/u/6371670?v=3" width="100px;"/><br /><sub><b>Turner Hayes</b></sub>](https://github.com/turnerhayes)<br />[馃悰](https://github.com/kentcdodds/cross-env/issues?q=author%3Aturnerhayes "Bug reports") [馃捇](https://github.com/kentcdodds/cross-env/commits?author=turnerhayes "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=turnerhayes "Tests") | [<img src="https://avatars2.githubusercontent.com/u/22251956?v=4" width="100px;"/><br /><sub><b>Suhas Karanth</b></sub>](https://github.com/sudo-suhas)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=sudo-suhas "Code") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=sudo-suhas "Tests") | [<img src="https://avatars3.githubusercontent.com/u/512692?v=4" width="100px;"/><br /><sub><b>Sven</b></sub>](https://github.com/sventschui)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=sventschui "Code") [馃摉](https://github.com/kentcdodds/cross-env/commits?author=sventschui "Documentation") [馃挕](#example-sventschui "Examples") [鈿狅笍](https://github.com/kentcdodds/cross-env/commits?author=sventschui "Tests") |
| [<img src="https://avatars0.githubusercontent.com/u/5522668?v=4" width="100px;"/><br /><sub><b>D. Nicol谩s Lopez Zelaya</b></sub>](https://github.com/NicoZelaya)<br />[馃捇](https://github.com/kentcdodds/cross-env/commits?author=NicoZelaya "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome!
Expand Down
17 changes: 9 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@ function parseCommand(args) {
} else {
// No more env setters, the rest of the line must be the command and args
let cStart = []
cStart = args.slice(i)
cStart = args
.slice(i)
// Regex:
// match "\'" or "'"
// or match "\" if followed by [$"\] (lookahead)
.map((a) => {
const re = new RegExp(/(\\)?'|([\\])(?=[$"\\])/, 'g')
// Eliminate all matches except for "\'" => "'"
return a.replace(re, (m) => {
if(m === "\\'") return "'"
return ""
.map(a => {
const re = /(\\)?'|([\\])(?=[$"\\])/g
// Eliminate all matches except for "\'" => "'"
return a.replace(re, m => {
if (m === "\\'") return "'"
return ''
})
})
})
command = cStart[0]
commandArgs = cStart.slice(1)
break
Expand Down

0 comments on commit 3cf4170

Please sign in to comment.