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

fixed #13445 - the Windows package launcher script can now pass all a… #13446

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions packager/__tests__/launchPackagerCLIMock.js.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

// Remove the first two elements, we only want the arguments
process.argv.splice(0, 2);

// Print out the arguments to be used in the test
console.log(process.argv.join(';;'));
12 changes: 12 additions & 0 deletions packager/__tests__/launchPackagerMock.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:: Copyright (c) 2015-present, Facebook, Inc.
:: All rights reserved.
::
:: This source code is licensed under the BSD-style license found in the
:: LICENSE file in the root directory of this source tree. An additional grant
:: of patent rights can be found in the PATENTS file in the same directory.

@echo off
title React Packager
node "$THIS_DIR/launchPackagerCLIMock.js.mock" start %*
pause
exit
11 changes: 11 additions & 0 deletions packager/__tests__/launchPackagerMock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

THIS_DIR=$(dirname "$0")
node "$THIS_DIR/launchPackagerCLIMock.js.mock" start "$@"
33 changes: 33 additions & 0 deletions packager/__tests__/packagerLauncher.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

jest.autoMockOff();

const onWindows = /^win/.test(process.platform);
const { spawnSync } = require('child_process');

describe('packager launcher', () => {
it('should be able to pass all arguments to the command-line script', () => {
// Determine the appropriate script to test based on the host OS
const cmd = `./packager/__tests__/launchPackagerMock.${onWindows ? 'bat' : 'sh'}`;

// Let's try to pass some args
const args = ['--arg1', '--arg2'];
const proc = spawnSync(cmd, args);

// We should've gotten the args from the mock script
const outArgs = proc.stdout.toString().trim().split(";;");

// We account for an extra arg in the mock scripts
expect(outArgs[1]).toEqual(args[0]);
expect(outArgs[2]).toEqual(args[1]);
});
});
2 changes: 1 addition & 1 deletion packager/launchPackager.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@echo off
title React Packager
node "%~dp0..\local-cli\cli.js" start
node "%~dp0..\local-cli\cli.js" start %*
pause
exit