Skip to content

Commit 1f98f3a

Browse files
committed
Fix to get file with extension from path
1 parent f10c26a commit 1f98f3a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

syncFixtures.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,28 @@ const syncFixtures = ({ souceFilePaths, dest }: SyncFixturesType) => {
1616
.sync(pattern, {
1717
cwd
1818
})
19-
.forEach(file => {
19+
.forEach(filePath => {
20+
const file = getFileNameFromPath(filePath);
2021
try {
2122
fs.copyFileSync(
22-
path.join(__dirname, `${cwd}/${file}`),
23+
path.join(__dirname, `${cwd}/${filePath}`),
2324
`${dest}/${file}`
2425
);
25-
console.log(`${file} was copied`);
26+
console.log(`${filePath} was copied`);
2627
} catch (error) {
2728
console.error(error);
2829
}
2930
});
3031
});
3132
};
3233

34+
const getFileNameFromPath = (filePath: string) => filePath.split("/").pop();
35+
3336
const souceFilePaths = [
3437
{
3538
cwd:
36-
"../relay/packages/relay-compiler/language/javascript/__tests__/fixtures/flow-generator/useHaste",
37-
pattern: "*.graphql"
39+
"../relay/packages/relay-compiler/language/javascript/__tests__/fixtures/flow-generator",
40+
pattern: "**/*.graphql"
3841
}
3942
];
4043

0 commit comments

Comments
 (0)