-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy LICENSE files when building packages
- Loading branch information
1 parent
b81a293
commit 5c6ecd7
Showing
6 changed files
with
54 additions
and
0 deletions.
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,6 @@ | ||
--- | ||
'modular-scripts': minor | ||
--- | ||
|
||
- Fix prefixed logger debug method logging as info | ||
- Copy LICENSE files when building packages |
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
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 |
---|---|---|
|
@@ -313,6 +313,7 @@ export async function makeBundle( | |
'dist-es', | ||
'dist-types', | ||
'README.md', | ||
'LICENSE', | ||
]), | ||
}; | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/modular-scripts/src/build/buildPackage/maybeCopyRootLicense.ts
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,35 @@ | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
import globby from 'globby'; | ||
import getPrefixedLogger from '../../utils/getPrefixedLogger'; | ||
import getModularRoot from '../../utils/getModularRoot'; | ||
|
||
const licenseGlob = 'LICEN@(C|S)E*'; | ||
|
||
export async function maybeCopyRootLicense( | ||
target: string, | ||
targetOutputDirectory: string, | ||
) { | ||
const logger = getPrefixedLogger(target); | ||
const modularRoot = getModularRoot(); | ||
const matches = globby.sync(path.join(targetOutputDirectory, licenseGlob), { | ||
cwd: modularRoot, | ||
onlyFiles: true, | ||
}); | ||
if (matches.length === 0) { | ||
logger.debug( | ||
`No license found in ${targetOutputDirectory}. Looking for root license.`, | ||
); | ||
const rootLicenses = globby.sync(path.join(modularRoot, licenseGlob), { | ||
cwd: modularRoot, | ||
onlyFiles: true, | ||
}); | ||
if (rootLicenses.length > 0) { | ||
rootLicenses.forEach((license) => { | ||
const filename = path.basename(license); | ||
logger.log(`Copying ${filename} found in ${modularRoot}`); | ||
fs.copyFileSync(license, path.join(targetOutputDirectory, filename)); | ||
}); | ||
} | ||
} | ||
} |