-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
package.json: script dist:zip packs with "katex" directory prefix again #1665
Conversation
CLA signature looks good 👍 |
Codecov Report
@@ Coverage Diff @@
## master #1665 +/- ##
=======================================
Coverage 93.84% 93.84%
=======================================
Files 78 78
Lines 4568 4568
Branches 801 801
=======================================
Hits 4287 4287
Misses 248 248
Partials 33 33 Continue to review full report at Codecov.
|
package.json
Outdated
@@ -90,7 +90,7 @@ | |||
"build": "yarn prestart && rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c && webpack", | |||
"watch": "yarn build --watch", | |||
"dist": "yarn test && yarn build && yarn dist:zip", | |||
"dist:zip": "cd dist && tar czf ../katex.tar.gz * && zip -rq ../katex.zip *" | |||
"dist:zip": "(set -e; test ! -d katex; trap 'rm -rf katex' EXIT; cp -R dist katex; tar czf katex.tar.gz katex; rm -f katex.zip; zip -rq katex.zip katex)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aim NPM scripts to be cross-platform, including Windows, as possible. Therefore unfortunately, we cannot use POSIX features. Also please use rimraf
instead of rm
.
Hmm. It seems I cannot make this both cross-platform and as noninvasive as I'd like. Therefore I withdraw this pull request. |
I think we can just do: |
Note that |
That said, beginning with an unconditional |
Besides, is the
might do the trick. |
My guess would be that, if someone has [followup] And I think |
I do not know |
@ccorn The issue is that we need the files in |
The following seems to work. This configures the output directory for diff --git a/package.json b/package.json
index c54e8ac..5ab317d 100644
--- a/package.json
+++ b/package.json
@@ -87,10 +87,10 @@
"prestart": "node check-node-version.js && yarn check && node src/unicodeMake.js",
"start": "webpack-dev-server --hot --config webpack.dev.js",
"analyze": "webpack --config webpack.analyze.js",
- "build": "yarn prestart && rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c && webpack",
+ "build": "yarn prestart && rimraf dist/ && mkdirp dist/katex && cp README.md dist/katex && rollup -c && webpack",
"watch": "yarn build --watch",
"dist": "yarn test && yarn build && yarn dist:zip",
- "dist:zip": "cd dist && tar czf ../katex.tar.gz * && zip -rq ../katex.zip *"
+ "dist:zip": "rimraf katex.tar.gz katex.zip && cd dist && tar czf ../katex.tar.gz katex && zip -rq ../katex.zip katex"
},
"dependencies": {
"commander": "^2.16.0"
diff --git a/rollup.config.js b/rollup.config.js
index 092c3c4..3fd7708 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -5,7 +5,7 @@ process.env.BABEL_ENV = 'esm';
export default {
input: 'katex.js',
output: {
- file: 'dist/katex.mjs',
+ file: 'dist/katex/katex.mjs',
format: 'es',
},
plugins: [
diff --git a/webpack.common.js b/webpack.common.js
index 3815bc6..42c0e88 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -70,7 +70,7 @@ function createConfig(target /*: Target */, dev /*: boolean */,
// Enable output modules to be used in browser or Node.
// See: https://github.com/webpack/webpack/issues/6522
globalObject: "(typeof self !== 'undefined' ? self : this)",
- path: path.resolve(__dirname, 'dist'),
+ path: path.resolve(__dirname, 'dist/katex'),
publicPath: dev ? '/' : '',
},
module: { |
@edemaine: Sorry, I have noticed your answer too late. Well then. The direct way is not an option then. |
Out of curiosity, since |
Ah I see, the |
Please do not wait for a pull request from me. In most KaTeX matters, I feel like a bull in a china shop. You would have to review it anyway, and it's probably easier for you to write the line yourself. |
I wonder there is anyone who has a file or folder named
Thank you for pointing that out. I didn't know
Unfortunately, |
Could you change the rimraf katex/ katex.tar.gz katex.zip && cp -R dist katex && tar czf katex.tar.gz katex && zip -rq katex.zip katex && rimraf katex/ and add |
Deliberately not adding |
The above commit line uses the exact script proposal by @ylemkinon. The commit makes I had to use |
Could you merge latest |
…gain. It does so by mercilessly removing the katex/ folder, if it exists (presumably left by previous failed dist:zip attempts), copying dist/ to katex/, and archiving the latter. On success, katex/ gets removed. Settled on this version after a more sophisticated script was considered to use too much POSIX features (like set and trap) in KaTeX#1665. Deliberately not adding katex/ to .gitignore because if katex/ shows up, it indicates that the latest dist attempt has not completed successfully.
Rebased (and retested with |
Thank you! |
This addresses #1664.
yarn dist:zip
now creates a temporary copy ofdist
tokatex
and tars/zips that folder instead of just its contents. This restores the release structure beforev0.10.0-rc
.Caveat: I am not familiar with
npm
noryarn
(beyond the basics) nor the KaTeX build system. I am familiar with Unix shell scripting however. Please review this pull request thoroughly. There may be other approaches that fit your philosophy or design goals better.Details:
set -e
makes the shell exit on errors (in simple commands); this saves lots of&&
and turns thetest ! -d katex
into an assertion. The(...)
open a subshell. This might not be necessary ifyarn
uses a separate shell process for each script anyway, but I use parentheses as part of an idiom whenever I usetrap
. (Because it enables nesting, and with the parentheses you can try the script directly in an interactivebash
session.) Thattrap
registers cleanup commands, to be run whenever (and however) the subshell exits, i.e. at the)
or upon errors (because of theset -e
) or signals as sent by hitting Ctrl-C. In this case, the trap makes sure that the temporarykatex
folder is deleted on exit, even in case of errors.The patch makes
yarn dist
producekatex.tar.gz
andkatex.zip
, each containing a single (filled) folderkatex
. All five test suites invoked byyarn test
pass.I had to use
yarn upgrade
and myyarn.lock
differs, but I have not included those changes because I think those are platform-specific.