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

Increased specificity of Windows platform check #2262

Merged
merged 3 commits into from
Dec 15, 2016
Merged

Increased specificity of Windows platform check #2262

merged 3 commits into from
Dec 15, 2016

Conversation

polizz
Copy link
Contributor

@polizz polizz commented Dec 15, 2016

Summary
Extended regex to match only Windows. Previous regex was matching Darwin in addition to Windows.

yarn run test > all tests pass.

#2261

@@ -68,7 +68,7 @@ export async function run(
for (const action of actions) {
const cmd = scripts[action];
if (cmd) {
const isWin = /win/.test(process.platform);
const isWin = /win32/.test(process.platform);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just be process.platform === 'win32'? Looks like that's what Node.js itself does, so it should be safe: https://github.com/nodejs/node/blob/db1087c9757c31a82c50a1eba368d8cba95b57d0/lib/os.js#L6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly. I noticed another section in execute-lifecycle that does just that.

@@ -131,3 +131,11 @@ export async function run<T, R>(
throw new Error(`${err && err.stack} \nConsole output:\n ${out}`);
}
}
export const setPlatform = (platform : string) : string => {
const previous = process.platform;
Object.defineProperty(process, 'platform', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish Node.js had a decent dependency injection framework, this is super hacky 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to redo that. It's not effective at all 😰 I originally was pondering just passing platform into run so the test could directly send it, but, to your point, that seems corny.

@Daniel15 Daniel15 merged commit 73d9e70 into yarnpkg:master Dec 15, 2016
Daniel15 pushed a commit that referenced this pull request Dec 20, 2016
The original test asserts that window cmd line formatting is properly applied or not applied, for only the target platform the tests are executed on - that will have to be good enough.

It is not possible to test both branches from one platform because the path module employed in the test alters its export based on process.platform in Node bootstrap, well before one can mock it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants