Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 64de514

Browse files
committed
Call syncFixture from ts file
1 parent 2b315e8 commit 64de514

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"prettier": "prettier --write '{src,types,test}/**/*.ts'",
3939
"prepublish": "npm run build",
4040
"relay": "node bin/relay-compiler.js --schema test/schema.graphql --src test/ --outputDir __generated__",
41-
"sync-fixtures": "rsync -avh --delete --stats --progress ../relay/packages/relay-compiler/language/javascript/__tests__/fixtures/flow-generator/**/*.graphql test/fixtures/type-generator",
41+
"sync-fixtures": "ts-node ./syncFixture.ts",
4242
"test": "npm run type-check && jest",
4343
"watch": "concurrently 'tsc --watch' 'chokidar \"lib/**/*.js\" -c \"yalc publish --force --push\"'",
4444
"type-check": "tsc --noEmit --pretty"

syncFixture.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as fs from "fs";
2+
import * as glob from "glob";
3+
import * as path from "path";
4+
5+
type SyncFixturesType = {
6+
souceFilePaths: Array<{
7+
cwd: string;
8+
pattern: string;
9+
}>;
10+
dest: string;
11+
};
12+
13+
const syncFixtures = ({ souceFilePaths, dest }: SyncFixturesType) => {
14+
souceFilePaths.forEach(({ cwd, pattern }) => {
15+
glob
16+
.sync(pattern, {
17+
cwd
18+
})
19+
.forEach(file => {
20+
try {
21+
fs.copyFileSync(
22+
path.join(__dirname, `${cwd}/${file}`),
23+
`${dest}/${file}`
24+
);
25+
console.log(`${file} was copied`);
26+
} catch (error) {
27+
console.error(error);
28+
}
29+
});
30+
});
31+
};
32+
33+
const souceFilePaths = [
34+
{
35+
cwd:
36+
"../relay/packages/relay-compiler/language/javascript/__tests__/fixtures/flow-generator/useHaste",
37+
pattern: "*.graphql"
38+
},
39+
{
40+
cwd:
41+
"../relay/packages/relay-compiler/codegen/__tests__/fixtures/compileRelayArtifacts",
42+
pattern: "append-edge.graphql"
43+
}
44+
];
45+
46+
syncFixtures({ souceFilePaths, dest: "./teste" });

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@
5353
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
5454
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
5555
},
56-
"include": ["./src/**/*", "./types/**/*"]
56+
"include": ["./src/**/*", "./types/**/*", "./syncFixture.ts"]
5757
}

0 commit comments

Comments
 (0)