shelljs / shx Goto Github PK
View Code? Open in Web Editor NEWPortable Shell Commands for Node
License: MIT License
Portable Shell Commands for Node
License: MIT License
If this is going to be MIT licensed, we should add that. If we're opting for the BSD license like shelljs, we should modify package.json and add the appropriate license file.
I only see CLI and npm script usage. Is ShellJS for JS and shx is for CLI?
Steps to reproduce:
$ npm install
$ npm run test:coverage # creates coverage/ directory
$ npm run lint # tries linting that directory, which isn't what we want
Hi guys,
What is the way to check the usb devices connected with shelljs?
Can I use libusb?
Thanks in advance, Nicholls
package.json
:
"devDependencies": {
"shx": "^0.1.4"
},
"scripts": {
"postinstall": "npm install shx && shx ln -s $(pwd) node_modules/self"
}
Works fine on Linux. On Windows:
node_modules/self was unexpected at this time.
C:\Users\M0on75e1l\node_modules\some> "C:\Users\M0on75e1l\node_modules\some\node_modules\.bin\\node.exe" "C:\Users\M0on75e1l\node_modules\some\node_modules\.bin\\..\shx\lib\cli.js" ln -s $(pwd) node_modules/self
npm WARN ENOENT ENOENT: no such file or directory, open 'C:\Users\M0on75e1l\package.json'
npm WARN EPACKAGEJSON M0on75e1l No description
npm WARN EPACKAGEJSON M0on75e1l No repository field.
npm WARN EPACKAGEJSON M0on75e1l No README data
npm WARN EPACKAGEJSON M0on75e1l No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]"
npm ERR! node v5.3.0
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `npm install shx && shx ln -s $(pwd) node_modules/self`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'npm install shx && shx ln -s $(pwd) node_modules/self'.
Reopening this, since it looks like one of our other issues got closed. I looked into test frameworks a bit more.
.serial
method for every test case, which sounds like a pain), feel free to correct me.I don't care too much which framework we use, as long as it works and ties into coverage tools. I'm mostly posting this as a reminder that we need some sort of unit tests.
It would be really convenient to have a kind of generic way to redirect output to:
/dev/null
(unix)NUL
(batch)$null
(powershell)I am trying to think about a syntax that would not be too heavy. Maybe an option like --null
.
What are your thoughts ?
Currently, it isn't possible to do something like cat file.txt | shx grep 'foo'
. It looks like shx isn't passing stdin along to the ShellJS command (although most commands actually support this).
This is currently blocking my work on shelljs/shelljs#525 (I'd like to replace .exec('grep...')
with .exec('shx grep...')
).
This should be an easy fix, if someone wants to take it up. Looks like we'll only have to change these lines to call the shelljs function with a different this
parameter (see the piping docs).
An upgrade request: if I run shx with no args (ls, pwd, etc), it would make sense to print out some sort of help messages. List the available commands?
The service appears to have been taken down (see lgtm.co). So we should:
.lgtm
and MAINTAINERS
should be the only ones I think)The following command is part of my "postinstall"-routine in package.json
:
shx cp node_modules/react/dist/react.min.js node_modules/react-dom/dist/react-dom.min.js node_modules/three/build/three.min.js app/static/
With v0.1.4 everything is working fine, but after updating my dependencies (shx v0.2.0) npm install
would not finish on travis or my buddies OSX; while i had no trouble running the script on windows.
Edit:
package.json
and other stuff can be found here
https://github.com/inikulin/publish-please
Cc @nfischer, we may want to use this package for super solid releases. Does security checks and guards against using regular npm release.
I might write "is logged in" and "has permission" checks for it if I start using it.
@ariporad it looks like I don't have complete access to shx. I'm missing the settings tab. Guessing this is why I also cannot setup coverage requirements for PRs. Could you grant me this perm or setup the repo?
What needs done:
It appears that the code coverage badge shows for the latest PR (that passes CI), not for the latest master branch. I noticed that the badge went up to 84% before merging the last PR. Currently, the latest passing PR and master branch have the same coverage, but this could probably be tested out by creating a fake PR that deletes the tests (0% coverage) and then I believe the badge icon will change.
Fixing this is probably as simple as changing a URL in the README badge.
[NOTE: @nfischer opened this to discuss adding a README, and I'm totally hijacking it. Sorry - @ariporad]
Ok, this issue will serve as the replacement for shelljs/shelljs#244. Feel free to discuss or provide feedback.
Things that need to be done prior to 1st release (which will hopefully be in conjunction with [email protected]
):
$ shx echo hello world
hello world
hello world
I think the simplest fix is to check for if we get echo
as a function, and not output its return value (since echo
already outputs things).
Confirmed by this comment. We should probably refactor our code to use the core API instead of our own implementation.
See #509
Hey,
I noticed that a lot of output gets missing when I pipe from shx cat
. However, shx cat
by itself seems to work fine.
Example:
shx cat src/app/**/*.js > /tmp/output && wc /tmp/output
15655 41088 460494 /tmp/output
shx cat src/app/**/*.js | wc
2181 5902 65536
For comparison:
cat src/app/**/*.js | wc
15655 41088 460494
I'm running 0.1.4
Was toying with a thin streaming wrapper around the shx
function. Would be cool to give this some thought. There is good potential to create a cross platform shell repl:
This also raised some issues with how we are accepting argv in shx
and parsing them in parseArgs. I'll wait until we get some of the other more fundamental issues/PRs cleared before digging in more.
Leaving this issue here as food for thought, for now.
.. doesn't work. Nor does npm install shelljs expose shx.
How do I do an npm install -D of shx?
Im attempting to copy node_modules to a build directory for packaging into an electron application.
It appears that shx silently fails after 72 items.
I checked to make sure it wasn't hiccuping on the last directory it copied 'history', by deleting 'history'. The next alphabetical directory was then copied but no more. ie I think theres a limit on the number of items that can be copied.
shx mkdir ./build/node_modules && shx cp -r ./src/node_modules/* ./build/node_modules
works fine, but
shx cp -r ./src/node_modules ./build/node_modules
does not, while
cp -r ./src/node_modules ./build/node_modules
works as expected.
Ive tried verbose logging, but it just reprints the command. Could it have anything to do with the ulimit being reached on the device as I know I had issues with that and webpack. The solution was to make webpack only process so many files at a time, as the ulimit couldn't be increased.
Im on OSX.
I'd like a cross-platform way of executing local executables, e.g. under *nix I can currently:
./local/path/executable
this doesn't work under windows because of the path representation ./
.
I was hoping I could run:
shx ./local/path/executable
But that doesn't seem to be supported.
Thanks! Otherwise awesome job!
The package.json
uses a call to rimraf
, but this is not available on node 4
. Should this be a dev dependency?
v7 is available on nvm
now, so we should make sure it's added to CI when possible:
@levithomason can take this, otherwise I'll get to it in a few days.
shx cd
can't ever work (a child process can't modify its parent process's working directory, for security reasons). We should output this as a warning, or just make shx cd
invalid.
If I run shx -h
I don’t see, for example, documentation about --noglob
. It’d be helpful if that was documented there for.
I tested in a1faf54 (v0.2.1) and it doesn’t appear to be there.
Is it possible to use sed in a npm run command? If so, could an example be provided? #
To write reasonably complex cross platform scripts, command substitution helps a ton. As a trivial example in package.json
shx rm $(shx pwd)/node_modules
I'm not familiar with the internals of shx, but it does seem like this could be tricky because it would require starting up potentially many sub-shells.
shx echo hello | shx sed 'hello' 'hola'
crashes with sed: no files given
despite the sed
command appearing to accept input from pipes.
$> ls
fileA fileB
$> shx cp -n fileA fileB
cp: dest file already exists: fileB
$> echo $?
130
$> cp -n fileA fileB # no output
$> echo $?
0 # no error
This is annoying when shx cp -n
is used in a npm script as the script will then stop.
Hello!
It would be great if someone could add -u flag support for cp command.
Right now output is following:
cp: option not recognized: u
Thanks in advance.
It would be very convenient to have a portable OR operator. I have no idea about the syntax, maybe a --or
flag:
$> shx foo --or bar
would execute:
node -e "require('child_process').exec('foo || bar')"
It would be nice if there was support for incorporating ShellJS plugins into shx, like so:
$ shx open file.txt
$ shx git status # assuming there is a git plugin
$ shx mktemp foo.XXXXXX
Since shx blacklists certain commands, it might be good to have some option when creating the ShellJS plugin about whether it will be exposed to shx
. This would also get rid of the need for a literal blacklist, since it would then be redundant.
The latest release for shx is broken. It looks like babel-polyfill
should actually be listed as a runtime dependency, not a dev dependency. It appears this is the only one so far.
I would recommend removing the current release (if it's possible to remove) and replacing it with a branch that has the fix.
Also, we should investigate ways to prevent slip-ups like this in the future, if at all possible. No good ideas come to my mind right now, however, since the dev dependencies are required to build the project.
I'm curious the possibility if shx could be a better alternative to run npm scripts in platform independent way
seems shelljs has cd
support but shx does not support shx cd
yet
I tried to install shx with npm (globaly, locally, as dep, as devDep) both linux and windows machines. But it breaks during linking. It looks like it does not find lib/cli.js
(see the log below).
npm install shelljs/shx
npm-debug.log
1095 verbose about to build /tmp/node_modules/shx/node_modules/shelljs
1096 info build /tmp/node_modules/shx/node_modules/shelljs
1097 info linkStuff [email protected]
1098 silly linkStuff [email protected] has /tmp/node_modules/shx/node_modules as its parent node_modules
1099 verbose linkBins [email protected]
1100 verbose link bins [ { shjs: './bin/shjs' },
1100 verbose link bins '/tmp/node_modules/shx/node_modules/.bin',
1100 verbose link bins false ]
1101 verbose linkMans [email protected]
1102 verbose rebuildBundles [email protected]
1103 verbose rebuildBundles [ 'glob', 'interpret', 'rechoir' ]
1104 silly gentlyRm /tmp/node_modules/shx/node_modules/.bin/shjs is being purged
1105 verbose gentlyRm don't care about contents; nuking /tmp/node_modules/shx/node_modules/.bin/shjs
1106 info install [email protected]
1107 info postinstall [email protected]
1108 verbose unlock done using /home/kirly/.npm/_locks/shelljs-4afc8c83066b6587.lock for /tmp/node_modules/shx/node_modules/shelljs
1109 verbose about to build /tmp/node_modules/shx
1110 info build /tmp/node_modules/shx
1111 info linkStuff [email protected]
1112 silly linkStuff [email protected] has /tmp/node_modules as its parent node_modules
1113 verbose linkBins [email protected]
1114 verbose link bins [ { shx: 'lib/cli.js' }, '/tmp/node_modules/.bin', false ]
1115 verbose linkMans [email protected]
1116 verbose rebuildBundles [email protected]
1117 verbose rebuildBundles [ '.bin', 'shelljs' ]
1118 verbose unlock done using /home/kirly/.npm/_locks/shx-f2158f07ac2468a2.lock for /tmp/node_modules/shx
1119 verbose stack Error: ENOENT, chmod '/tmp/node_modules/shx/lib/cli.js'
1119 verbose stack at Error (native)
1120 verbose cwd /tmp
1121 error Linux 3.16.0-4-amd64
1122 error argv "/usr/bin/node" "/usr/bin/npm" "i" "-D" "shelljs/shx"
1123 error node v0.12.8
1124 error npm v2.14.9
1125 error path /tmp/node_modules/shx/lib/cli.js
1126 error code ENOENT
1127 error errno -2
1128 error enoent ENOENT, chmod '/tmp/node_modules/shx/lib/cli.js'
1128 error enoent This is most likely not a problem with npm itself
1128 error enoent and is related to npm not being able to find a file.
1129 verbose exit [ -2, true ]
1130 verbose unbuild node_modules/shx
1131 info preuninstall [email protected]
1132 info uninstall [email protected]
1133 verbose unbuild rmStuff [email protected] from /tmp/node_modules
1134 silly gentlyRm /tmp/node_modules/.bin/shx is being gently removed
1135 silly gentlyRm verifying /tmp is an npm working directory
1136 silly gentlyRm containing path /tmp is under npm's control, in /tmp
1137 silly gentlyRm deletion target /tmp/node_modules/.bin/shx is under /tmp
1138 verbose gentlyRm vacuuming from /tmp/node_modules/.bin/shx up to /tmp
1139 info postuninstall [email protected]
1140 silly gentlyRm /tmp/node_modules/shx is being purged from base /tmp
1141 verbose gentlyRm don't care about contents; nuking /tmp/node_modules/shx
1142 silly vacuum-fs purging /tmp/node_modules/shx
1143 silly vacuum-fs removing /tmp/node_modules
1144 silly vacuum-fs finished vacuuming up to /tmp
One annoying difference between Windows' old shell and the Unix shell is the lack of globbing on Windows. shx already addresses this for shell builtins and coreutils by including globbing logic in each of the commands' implementations, but this still leaves external commands that weren't written with Windows in mind (and thus don't implement their own globbing) out in the cold.
Would you be open to a PR that adds a feature which simply globs all its arguments and runs the result?
For example, shx XXX foo *
would be equivalent to foo *
in a Unix shell.
As for naming, command
(like the bash builtin) might be an option. Or glob
. Or whatever; I'm not picky about the name.
Since we're planning to release this with v0.7, it makes more sense to have shelljs included as a submodule (since master is most of the way to v0.7).
Once v0.7 lands, we can swap out the submodule for a regular npm dependency. If all the tests pass, we can release it.
It'd be handy to add --version
to the shx
binary:
$ shx --version
0.2.2
This is handy when using shx
globally (which is the easiest way of reproducing bugs).
Per #58 (comment) it would be helpful to show the unsupported commands in the README. Also, giving some workarounds would be helpful.
This should have some basic unit tests (maybe one for each command, borrowed from shelljs's unit tests?). This should also get some sort of CI set up, as soon as the unit tests are written.
I think it would be helpful to add the unix true
and false
commands to shx
. I don't know if these should be added to ShellJS itself, or simply parsed out and interpreted directly in shx, though I think I'd lean toward the latter.
After upgrading to shx 0.2.1, i.e. a version with the fixed sed syntax, I can't replace strings with a blank string. The issue is likely in these regex.
shx echo 'foobar' | shx sed 'bar' '' # previous syntax, returned 'foo'
shx echo 'foobar' | shx sed 's/bar/lish/' # returns 'foolish'
shx echo 'foobar' | shx sed 's/bar/ /' # returns 'foo '
shx echo 'foobar' | shx sed 's/bar//' # crashes with 'sed: invalid replacement string'
echo 'foobar' | sed 's/bar//' # returns 'foo'
appveyor is still under Ari's account, which I don't have access to, so I can't restart failed builds.
I already have an appveyor account under the "shelljs" username, I just need to actually get around to switching this over.
I've noticed that iojs seems to be failing often on Travis, usually due to nvm
issues. We should probably consider allowing failures for iojs builds until things get consistent. Because we're testing on v0.12 and v4, it's pretty unlikely that those will pass but we'll get actual failures on iojs.
This way we can continue supporting iojs, but won't be bogged down by flakiness on the travis machines.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.