-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correctly copy over package.json file in the explorer-helpers package (…
- Loading branch information
1 parent
0ed9997
commit 3a8e666
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 mayakoneval | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const fs = require('fs-extra'); | ||
|
||
// We copy the package.json to the dist folder, since when we publish we | ||
// publish from inside the dist folder (see prepareForPublish node script). | ||
const packageJson = require('./package.json'); | ||
packageJson.type = 'module'; | ||
|
||
// Remove package.json items that we don't need to publish | ||
delete packageJson.scripts; | ||
delete packageJson.bundlesize; | ||
delete packageJson.engines; | ||
|
||
// The root package.json points to the CJS/ESM source in "dist", to support | ||
// on-going package development (e.g. running tests, supporting npm link, etc.). | ||
// When publishing from "dist" however, we need to update the package.json | ||
// to point to the files within the same directory. | ||
const distPackageJson = | ||
JSON.stringify( | ||
packageJson, | ||
(_key, value) => { | ||
if (typeof value === 'string' && value.startsWith('dist/')) { | ||
const parts = value.split('/'); | ||
parts.splice(0, 1); // remove dist | ||
return './' + parts.join('/'); | ||
} | ||
return value; | ||
}, | ||
2 | ||
) + '\n'; | ||
|
||
// Save the modified package.json to "dist" | ||
fs.writeFileSync(`./dist/package.json`, distPackageJson); | ||
|
||
// Copy supporting files into "dist" | ||
const destDir = `dist`; | ||
fs.copyFileSync(`README.md`, `${destDir}/README.md`); | ||
fs.copyFileSync(`LICENSE`, `${destDir}/LICENSE`); |