diff --git a/src/content/registry/npm.test.js b/src/content/registry/npm.test.js
index 050ab6a..cf7c5b8 100644
--- a/src/content/registry/npm.test.js
+++ b/src/content/registry/npm.test.js
@@ -116,5 +116,20 @@ describe('npm', () => {
expect(packagePosition).toStrictEqual(expectedPackages);
});
+
+ it('should break into commands', () => {
+ // https://stackoverflow.com/a/65043610/839513
+ const {
+ command,
+ positions,
+ } = cli`npm uninstall -g create-react-app && npm i -g ${'npm@latest'} && npm cache clean -f && npx ${'create-react-app@latest'} my-app --use-npm`;
+ const expectedPackages = positions.map(({ index, value }) =>
+ packageResult({ name: value.split('@')[0], startIndex: index, endIndex: index + value.length })
+ );
+
+ const packagePosition = parseCommand(command);
+
+ expect(packagePosition).toStrictEqual(expectedPackages);
+ });
});
});
diff --git a/src/content/registry/python.test.js b/src/content/registry/python.test.js
index c10809c..879c3d1 100644
--- a/src/content/registry/python.test.js
+++ b/src/content/registry/python.test.js
@@ -97,4 +97,19 @@ describe(parseCommand.name, () => {
expect(packagePosition).toStrictEqual(expectedPackages);
});
+
+ it('should break into commands', () => {
+ // https://stackoverflow.com/a/65043610/839513
+ const {
+ command,
+ positions,
+ } = cli`pip uninstall -y requests-temp && pip install ${'scipy'} && pip check --no-color && pip hash -V && pip install ${'numpy'}`;
+ const expectedPackages = positions.map(({ index, value }) =>
+ packageResult({ name: value.split('@')[0], startIndex: index, endIndex: index + value.length })
+ );
+
+ const packagePosition = parseCommand(command);
+
+ expect(packagePosition).toStrictEqual(expectedPackages);
+ });
});
diff --git a/src/content/registry/shared.js b/src/content/registry/shared.js
index fe72248..5b7d1df 100644
--- a/src/content/registry/shared.js
+++ b/src/content/registry/shared.js
@@ -18,7 +18,8 @@ export const createParseCommand =
const packages = [];
let counterIndex = 0;
- const lines = command.split('\n');
+ const lines = command.split(/\n|\s*&&\s*/);
+
while (lines.length > 0) {
const line = lines.shift();
diff --git a/tests/real-examples/real-examples-results.yaml b/tests/real-examples/real-examples-results.yaml
index 9cc5166..39ecef7 100644
--- a/tests/real-examples/real-examples-results.yaml
+++ b/tests/real-examples/real-examples-results.yaml
@@ -1485,6 +1485,301 @@ https://stackoverflow.com/questions/22563281:
type: npm
name: ios-sim
version: ~1.8
+https://stackoverflow.com/a/65043610/839513:
+ comment: multiple commands in the same line
+ post: answer
+ registry: npm
+ results:
+ - range: npm i create-react-app
+ type: npm
+ name: create-react-app
+ - range: npx create-react-app new-app
+ type: npm
+ name: create-react-app
+ - range: npm init react-app new-app
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app@latest your-project-name --use-npm
+
+ type: npm
+ name: create-react-app
+ - range: npm install -g create-react-app
+ type: npm
+ name: create-react-app
+ - range: npx create-react-app my-app
+ type: npm
+ name: create-react-app
+ - range: >-
+ npm uninstall -g create-react-app && npm i -g npm@latest
+ && npm cache clean -f && npx create-react-app@latest
+ my-app --use-npm
+
+
+ type: npm
+ name: npm
+ - range: >-
+ npm uninstall -g create-react-app && npm i -g npm@latest
+ && npm cache clean -f && npx create-react-app@latest
+ my-app --use-npm
+
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app@5.0.0 app-name
+
+ type: npm
+ name: create-react-app
+ version: 5.0.0
+ - range: npm install -g create-react-app
+ type: npm
+ name: create-react-app
+ - range: |-
+ # for npm:
+ npm i create-react-app
+
+ # for yarn:
+ yarn add create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ # for npm:
+ npm i create-react-app
+
+ # for yarn:
+ yarn add create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ # for npx:
+ npx create-react-app my-app
+
+ # for npm:
+ npm init react-app my-app
+
+ # for yarn:
+ yarn create react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ # for npx:
+ npx create-react-app my-app
+
+ # for npm:
+ npm init react-app my-app
+
+ # for yarn:
+ yarn create react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ # for npx:
+ npx create-react-app my-app
+
+ # for npm:
+ npm init react-app my-app
+
+ # for yarn:
+ yarn create react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: npx create-react-app my-app
+ type: npm
+ name: create-react-app
+ - range: npm install -g create-react-app
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm update npx
+
+ type: npm
+ name: npx
+ - range: npx create-react-app@latest my-app --template typescript
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm i create-react-app # or yarn add create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm uninstall -g create-react-app
+ npm install create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm install create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: npm install -g npm@latest
+ type: npm
+ name: npm
+ - range: |-
+ npm init react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ yarn create react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: npx create-react-app my-app
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app@4.0.2 my-app
+
+ type: npm
+ name: create-react-app
+ version: 4.0.2
+ - range: |-
+ npm install npm@latest -g
+
+ type: npm
+ name: npm
+ - range: npx create-react-app app_name
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx clear-npx-cache
+
+ type: npm
+ name: clear-npx-cache
+ - range: |-
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app appname
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ sudo npm uninstall create-react-app -g
+
+ sudo npm install create-react-app@5.0.0 -g
+
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ version: 5.0.0
+ - range: |-
+ sudo npm uninstall create-react-app -g
+
+ sudo npm install create-react-app@5.0.0 -g
+
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app@latest app-name
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm install -g npm@latest
+ npx create-react-app my-app
+
+ type: npm
+ name: npm
+ - range: |-
+ npm install -g npm@latest
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm uninstall -g create-react-app
+ npm install -g create-react-app
+ //OR
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm uninstall -g create-react-app
+ npm install -g create-react-app
+ //OR
+ npx create-react-app my-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm install create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: npx create-react-app my-app
+ type: npm
+ name: create-react-app
+ - range: npm install create-react-app
+ type: npm
+ name: create-react-app
+ - range: npm update npx
+ type: npm
+ name: npx
+ - range: npx create-react-app "your preferred project name"
+ type: npm
+ name: create-react-app
+ - range: >-
+ npm uninstall -g create-react-app && npm i -g npm@latest
+ && npm cache clean -f && npx create-react-app my-app
+
+
+ type: npm
+ name: npm
+ - range: >-
+ npm uninstall -g create-react-app && npm i -g npm@latest
+ && npm cache clean -f && npx create-react-app my-app
+
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm i create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm i create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: yarn add create-react-app
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm install -g create-react-app
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npx create-react-app <project_name>
+
+ type: npm
+ name: create-react-app
+ - range: |-
+ npm install -g create-react-app
+
+ type: npm
+ name: create-react-app
https://stackoverflow.com/questions/2817869:
comment: high scored
post: question
diff --git a/tests/real-examples/real-examples.yaml b/tests/real-examples/real-examples.yaml
index e044284..9b77532 100644
--- a/tests/real-examples/real-examples.yaml
+++ b/tests/real-examples/real-examples.yaml
@@ -76,6 +76,10 @@ links:
comment: with semver ~
post: answer
registry: npm
+ https://stackoverflow.com/a/65043610/839513:
+ comment: multiple commands in the same line
+ post: answer
+ registry: npm
https://stackoverflow.com/questions/2817869:
comment: high scored