Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build-clean-all": "rimraf ./packages/*/build ./packages/*/tsconfig.tsbuildinfo",
"watch": "node ./scripts/watch.js",
"test": "jest",
"test:ci:unit": "jest packages --ci --coverage",
"test:ci:unit": "jest packages scripts --ci --coverage",
"test:ci:e2e": "jest e2e --ci -i",
"lint": "eslint --ext .js,.ts . --cache --report-unused-disable-directives",
"postinstall": "yarn build",
Expand Down
48 changes: 48 additions & 0 deletions scripts/__tests__/build.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const {execFileSync} = require('child_process');
const fs = require('fs');
const path = require('path');

test('builds a package when its checkout path contains glob characters', () => {
const root = path.resolve(__dirname, '../..');
const checkout = fs.mkdtempSync(path.join(root, 'build-(fixture)-'));

try {
const scripts = path.join(checkout, 'scripts');
fs.mkdirSync(scripts);
for (const file of ['build.js', 'helpers.js']) {
fs.copyFileSync(
path.join(root, 'scripts', file),
path.join(scripts, file),
);
}
fs.copyFileSync(
path.join(root, 'babel.config.js'),
path.join(checkout, 'babel.config.js'),
);

const pkg = path.join(checkout, 'packages', 'example');
const src = path.join(pkg, 'src');
fs.mkdirSync(src, {recursive: true});
fs.writeFileSync(
path.join(src, 'index.ts'),
'export const value: number = 42;',
);

execFileSync(process.execPath, [path.join(scripts, 'build.js')], {
cwd: checkout,
});

expect(
fs.readFileSync(path.join(pkg, 'build', 'index.js'), 'utf8'),
).toContain('const value = 42;');
} finally {
fs.rmSync(checkout, {recursive: true, force: true});
}
});
7 changes: 3 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ function getBuildPath(file, buildFolder) {
}

function buildNodePackage(p) {
const srcDir = path.resolve(p, SRC_DIR);
const pattern = path.resolve(srcDir, '**/*');
const files = glob.sync(pattern, {
nodir: true,
const files = glob.sync('**/*', {
cwd: path.resolve(p, SRC_DIR),
absolute: true,
});

process.stdout.write(adjustToTerminalWidth(`${path.basename(p)}\n`));
Expand Down
Loading