File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
- rm -rf examples
3
+ rm -rf dist
4
4
rm swagger-codegen-cli-v2.jar
5
5
rm swagger-codegen-cli-v3.jar
6
6
Original file line number Diff line number Diff line change
1
+ import { relative } from 'path' ;
2
+
3
+ export function isSubDirectory ( parent : string , child : string ) {
4
+ return relative ( child , parent ) . startsWith ( '..' ) ;
5
+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { resolve } from 'path';
3
3
import { Client } from '../client/interfaces/Client' ;
4
4
import { HttpClient } from '../index' ;
5
5
import { mkdir , rmdir } from './fileSystem' ;
6
+ import { isSubDirectory } from './isSubdirectory' ;
6
7
import { Templates } from './registerHandlebarTemplates' ;
7
8
import { writeClientCore } from './writeClientCore' ;
8
9
import { writeClientIndex } from './writeClientIndex' ;
@@ -41,6 +42,10 @@ export async function writeClient(
41
42
const outputPathSchemas = resolve ( outputPath , 'schemas' ) ;
42
43
const outputPathServices = resolve ( outputPath , 'services' ) ;
43
44
45
+ if ( ! isSubDirectory ( process . cwd ( ) , output ) ) {
46
+ throw new Error ( `Output folder is not a subdirectory of the current working directory` ) ;
47
+ }
48
+
44
49
await rmdir ( outputPath ) ;
45
50
await mkdir ( outputPath ) ;
46
51
You can’t perform that action at this time.
0 commit comments