-
Notifications
You must be signed in to change notification settings - Fork 13
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
Sdfix #45
Merged
Merged
Sdfix #45
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
22e354e
Update scripts to cd back to MATLAB startup directory
sameagen-MW 528968e
Debug
sameagen-MW 64eae86
Revert to using a script, pass the old directory through via environm…
sameagen-MW e45a2b1
Add check
sameagen-MW cf379d1
Fix syntax
sameagen-MW b3dd7cf
Sneaky sneaky variable name
sameagen-MW 435144e
Put startup in the correct directory
sameagen-MW 4c8ee92
Spelling is hard
sameagen-MW 3fdaf00
Character vector changes
sameagen-MW 6b3cf41
Update quotes
sameagen-MW 0e4d45e
Move function call location
sameagen-MW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2020 The MathWorks, Inc. | ||
// Copyright 2020-2023 The MathWorks, Inc. | ||
|
||
/** | ||
* Generate MATLAB command for changing directories and calling a command in it. | ||
|
@@ -7,8 +7,8 @@ | |
* @param command Command to run in directory. | ||
* @returns MATLAB command. | ||
*/ | ||
export function cdAndCall(dir: string, command: string): string { | ||
return `cd('${pathToCharVec(dir)}');${command}`; | ||
export function cdAndCall(command: string): string { | ||
return `cd(getenv("MW_ORIG_WORKING_FOLDER"));${command}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
/** | ||
|
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 |
---|---|---|
@@ -1,15 +1,14 @@ | ||
// Copyright 2020 The MathWorks, Inc. | ||
// Copyright 2020-2023 The MathWorks, Inc. | ||
|
||
import * as script from "./script"; | ||
|
||
describe("call generation", () => { | ||
it("ideally works", () => { | ||
// I know what your thinking | ||
const testDir = String.raw`C:\Users\you\You're Documents`; | ||
const testCommand = "disp('hello world')"; | ||
const expectedString = String.raw`cd('C:\Users\you\You''re Documents');${testCommand}`; | ||
const expectedString = `cd(getenv("MW_ORIG_WORKING_FOLDER"));${testCommand}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
expect(script.cdAndCall(testDir, testCommand)).toMatch(expectedString); | ||
expect(script.cdAndCall(testCommand)).toMatch(expectedString); | ||
}); | ||
}); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to escape
'
s here right before injecting it into the char array. Then all users of this function don't need to know they need to escape the dir before calling this function and the need to escape is implementation detail of this function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that mean that the other function consumers would likely have to escape the dir themselves later on? I can't think of many cases where someone would be calling
generateScript
and not wanting the directory to be escaped but i'm probably missing somethingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generateScript
just generates a script and returns the directory that script lives in. It shouldn't assume you're then going to inject that directory path into a MATLAB char array later on. If, for instance, you wanted to delete that directory from JavaScript code, you've got an issue because the directory path is wrong.