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

adding create-data-dir batch file for windows #1162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

huaigulin
Copy link

@huaigulin huaigulin commented Jun 9, 2020

Description of proposed changes

This pull request can make installation on Windows much easier. It adds a Windows batch .bat file, which is Windows' equivalent of .sh script in Linux.

The only reason that npm install --global . fails in Windows is that Windows cannot execute Linux shell script and therefore does not support env command used in create-data-dir in package.json.

After taking a look at create-data-dir.sh, I think all it does is just creating two empty directories. Therefore we can write a .bat file to create those directories in Windows. And the npm install --global . command will succeed, without needing to create a Linux subsystem.

Related issue(s)

Fixes #
Related to #1100

Testing

For testing, I changed the create-data-dir command of package.json in my local environment to ".\\scripts\\create-data-dir.bat". Note that Windows directory separator is \ and has to be escaped in package.json, hence we see the weird-looking \\.

After changing create-data-dir command, npm install --global . ran successfully in Windows Powershell without npm errors:

(auspice) PS C:\...\auspice> npm install --global .
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
C:\...\.conda\envs\auspice\auspice -> C:\...\.conda\envs\auspice\node_modules\auspice\auspice.js

> [email protected] postinstall C:\...\.conda\envs\auspice\node_modules\auspice
> npm run create-data-dir


> [email protected] create-data-dir C:\...\.conda\envs\auspice\node_modules\auspice
> .\scripts\create-data-dir.bat


C:\...\.conda\envs\auspice\node_modules\auspice>if not exist data (
echo "Creating empty data directory"
 mkdir data
)
"Creating empty data directory"

C:\...\.conda\envs\auspice\node_modules\auspice>if not exist narratives (
echo "Creating empty narratives directory"
 mkdir narratives
)
"Creating empty narratives directory"
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules\auspice\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\auspice\node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] requires a peer of react@^15.4.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @types/react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.

+ [email protected]
updated 1 package in 5.884s

The two empty directories were also successfully created:
image

Next Step

We could simply update installation instructions to let Windows users know how to change package.json and then run npm install --global .. A more advanced/automated solution would be detecting OS then running the corresponding type of script.

Thank you for contributing to Nextstrain!

@huaigulin
Copy link
Author

huaigulin commented Jun 9, 2020

I can also help creating batch file for other shell scripts, like get-data.sh etc.

@huaigulin huaigulin changed the title adding batch file for windows adding create-data-dir batch file for windows Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant