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

New plugin for unix-only features and extensions #748

Open
nfischer opened this issue Jun 21, 2017 · 0 comments
Open

New plugin for unix-only features and extensions #748

nfischer opened this issue Jun 21, 2017 · 0 comments
Labels

Comments

@nfischer
Copy link
Member

Originally discussed with @bruce-one on #727, shifting the discussion to a dedicated issue.

While ShellJS aims to be cross-platform, it's often impossible to support posix behavior while also operating on Windows. For example, cp on unix supports FIFOs and special devices, neither of which really exists on Windows.

Supporting these edge cases within shelljs leads to a lot of platform-dependent code paths. Such code paths are risky, because they inherently can't be tested on Windows. This adds extra complexity, while also making our module behave inconsistently across platforms. Worse yet, if a logic bug sends us down such a code path on Windows, then we'll have unpredictable behavior.


The proposed solution is to treat special unix edge cases as error cases in shelljs. We'll then add explicit support for them in an optional plugin (perhaps named shelljs-plugin-unix). Some initial thoughts on the plugin:

  • Only supports unix. We can enforce this in our package.json with "os" : [ "darwin", "linux" ] or "os" : [ "!win32" ]. No process.platform checks needed 🎉
  • ShellJS must behave sensibly without the plugin. It's only intended to give more posix compliance for those who need it
  • First use case is to extend core shelljs commands (e.g. cp(), rm(), etc.) with support for fifo and block/character device
  • This might eventually support some of our unix-only commands, like chmod()
  • Support should be provided by overriding specific methods (e.g. handleSpecialFiles()). Similar concept as a subclass overriding a parent method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant