| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d93cff5 commit 4bfcad1
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,26 +43,11 @@ const argsWithoutWatchOptions = []; | |||
| 43 | 43 | ||
| 44 | 44 | for (let i = 0; i < process.execArgv.length; i++) { | |
| 45 | 45 | const arg = process.execArgv[i]; | |
| 46 | - if (StringPrototypeStartsWith(arg, '--watch=')) { | ||
| 47 | - continue; | ||
| 48 | - } | ||
| 49 | - if (arg === '--watch') { | ||
| 50 | - const nextArg = process.execArgv[i + 1]; | ||
| 51 | - if (nextArg && nextArg[0] !== '-') { | ||
| 52 | - // If `--watch` doesn't include `=` and the next | ||
| 53 | - // argument is not a flag then it is interpreted as | ||
| 54 | - // the watch argument, so we need to skip that as well | ||
| 55 | - i++; | ||
| 56 | - } | ||
| 57 | - continue; | ||
| 58 | - } | ||
| 59 | - if (StringPrototypeStartsWith(arg, '--watch-path')) { | ||
| 60 | - const lengthOfWatchPathStr = 12; | ||
| 61 | - if (arg[lengthOfWatchPathStr] !== '=') { | ||
| 62 | - // if --watch-path doesn't include `=` it means | ||
| 63 | - // that the next arg is the target path, so we | ||
| 64 | - // need to skip that as well | ||
| 65 | - i++; | ||
| 46 | + if (StringPrototypeStartsWith(arg, '--watch')) { | ||
| 47 | + i++; | ||
| 48 | + const nextArg = process.execArgv[i]; | ||
| 49 | + if (nextArg && nextArg[0] === '-') { | ||
| 50 | + ArrayPrototypePush(argsWithoutWatchOptions, nextArg); | ||
| 66 | 51 | } | |
| 67 | 52 | continue; | |
| 68 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -791,54 +791,4 @@ process.on('message', (message) => { | |||
| 791 | 791 | `Completed running ${inspect(file)}. Waiting for file changes before restarting...`, | |
| 792 | 792 | ]); | |
| 793 | 793 | }); | |
| 794 | - | ||
| 795 | - it('when multiple `--watch` flags are provided should run as if only one was', async () => { | ||
| 796 | - const projectDir = tmpdir.resolve('project-multi-flag'); | ||
| 797 | - mkdirSync(projectDir); | ||
| 798 | - | ||
| 799 | - const file = createTmpFile(` | ||
| 800 | - console.log( | ||
| 801 | - process.argv.some(arg => arg === '--watch') | ||
| 802 | - ? 'Error: unexpected --watch args present' | ||
| 803 | - : 'no --watch args present' | ||
| 804 | - );`, '.js', projectDir); | ||
| 805 | - const args = ['--watch', '--watch', file]; | ||
| 806 | - const { stdout, stderr } = await runWriteSucceed({ | ||
| 807 | - file, watchedFile: file, watchFlag: null, args, options: { cwd: projectDir } | ||
| 808 | - }); | ||
| 809 | - | ||
| 810 | - assert.strictEqual(stderr, ''); | ||
| 811 | - assert.deepStrictEqual(stdout, [ | ||
| 812 | - 'no --watch args present', | ||
| 813 | - `Completed running ${inspect(file)}`, | ||
| 814 | - `Restarting ${inspect(file)}`, | ||
| 815 | - 'no --watch args present', | ||
| 816 | - `Completed running ${inspect(file)}`, | ||
| 817 | - ]); | ||
| 818 | - }); | ||
| 819 | - | ||
| 820 | - it('`--watch-path` ars without `=` used alongside `--watch` should not make it into the script', async () => { | ||
| 821 | - const projectDir = tmpdir.resolve('project-watch-watch-path-args'); | ||
| 822 | - mkdirSync(projectDir); | ||
| 823 | - | ||
| 824 | - const file = createTmpFile(` | ||
| 825 | - console.log( | ||
| 826 | - process.argv.slice(2).some(arg => arg.endsWith('.js')) | ||
| 827 | - ? 'some cli args end with .js' | ||
| 828 | - : 'no cli arg ends with .js' | ||
| 829 | - );`, '.js', projectDir); | ||
| 830 | - const args = ['--watch', `--watch-path`, file, file]; | ||
| 831 | - const { stdout, stderr } = await runWriteSucceed({ | ||
| 832 | - file, watchedFile: file, watchFlag: null, args, options: { cwd: projectDir } | ||
| 833 | - }); | ||
| 834 | - | ||
| 835 | - assert.strictEqual(stderr, ''); | ||
| 836 | - assert.deepStrictEqual(stdout, [ | ||
| 837 | - 'no cli arg ends with .js', | ||
| 838 | - `Completed running ${inspect(file)}`, | ||
| 839 | - `Restarting ${inspect(file)}`, | ||
| 840 | - 'no cli arg ends with .js', | ||
| 841 | - `Completed running ${inspect(file)}`, | ||
| 842 | - ]); | ||
| 843 | - }); | ||
| 844 | 794 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments