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

fix: change permission in launchPackager.command when building packages #1904

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const BUILD_DIR = 'build';
const JS_FILES_PATTERN = '**/*.js';
const TS_FILE_PATTERN = '**/*.ts';
const IGNORE_PATTERN = '**/__{tests,mocks,fixtures}__/**';
const FILES_WITH_755_PERMISSION = ['launchPackager.command'];

const transformOptions = require('../babel.config.js');

Expand Down Expand Up @@ -79,11 +80,19 @@ function buildFile(file, silent) {

fs.mkdirSync(path.dirname(destPath), {mode: 0o777, recursive: true});

const fileName = path.basename(file);

if (
!micromatch.isMatch(file, JS_FILES_PATTERN) &&
!micromatch.isMatch(file, TS_FILE_PATTERN)
) {
fs.createReadStream(file).pipe(fs.createWriteStream(destPath));
if (FILES_WITH_755_PERMISSION.includes(fileName)) {
fs.createReadStream(file).pipe(
fs.createWriteStream(destPath, {mode: 0o755}),
);
} else {
fs.createReadStream(file).pipe(fs.createWriteStream(destPath));
}
silent ||
process.stdout.write(
`${
Expand All @@ -95,12 +104,11 @@ function buildFile(file, silent) {
);
} else {
const options = Object.assign({}, transformOptions);
const filename = path.basename(destPath);

let {code, map} = babel.transformFileSync(file, options);

if (!file.endsWith('.d.ts') && map.sources.length > 0) {
code = `${code}\n\n//# sourceMappingURL=${filename}.map`;
code = `${code}\n\n//# sourceMappingURL=${fileName}.map`;
map.sources = [path.relative(path.dirname(destPath), file)];
fs.writeFileSync(`${destPath}.map`, JSON.stringify(map));
}
Expand Down