mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-20 19:47:52 +02:00
fix(create-docusaurus): fix CLI and remove shelljs escapeShellArg util (#10958)
This commit is contained in:
parent
2976dfea72
commit
dec3bcbbd7
4 changed files with 6 additions and 45 deletions
|
@ -1,19 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {escapeShellArg} from '../shellUtils';
|
||||
|
||||
describe('shellUtils', () => {
|
||||
it('escapeShellArg', () => {
|
||||
expect(escapeShellArg('hello')).toBe("'hello'");
|
||||
expect(escapeShellArg('*')).toBe("'*'");
|
||||
expect(escapeShellArg('hello world')).toBe("'hello world'");
|
||||
expect(escapeShellArg("'hello'")).toBe("\\''hello'\\'");
|
||||
expect(escapeShellArg('$(pwd)')).toBe("'$(pwd)'");
|
||||
expect(escapeShellArg('hello$(pwd)')).toBe("'hello$(pwd)'");
|
||||
});
|
||||
});
|
|
@ -107,7 +107,6 @@ export {
|
|||
getWebpackLoaderCompilerName,
|
||||
type WebpackCompilerName,
|
||||
} from './webpackUtils';
|
||||
export {escapeShellArg} from './shellUtils';
|
||||
export {loadFreshModule} from './moduleUtils';
|
||||
export {
|
||||
getDataFilePath,
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// TODO move from shelljs to execa later?
|
||||
// Execa is well maintained and widely used
|
||||
// Even shelljs recommends execa for security / escaping:
|
||||
// https://github.com/shelljs/shelljs/wiki/Security-guidelines
|
||||
|
||||
// Inspired by https://github.com/xxorax/node-shell-escape/blob/master/shell-escape.js
|
||||
export function escapeShellArg(s: string): string {
|
||||
let res = `'${s.replace(/'/g, "'\\''")}'`;
|
||||
res = res.replace(/^(?:'')+/g, '').replace(/\\'''/g, "\\'");
|
||||
return res;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue