two-stroke 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/test.ts +21 -13
package/package.json
CHANGED
package/src/test.ts
CHANGED
|
@@ -65,21 +65,29 @@ export const setupTests = async <Paths extends {}>(bindings: Env) => {
|
|
|
65
65
|
const d1 = await miniflare.getD1Database(binding);
|
|
66
66
|
|
|
67
67
|
const migrationsDir = "./migrations";
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
68
|
+
let fileNames: string[] = [];
|
|
69
|
+
try {
|
|
70
|
+
fileNames = await nodefs.readdir(migrationsDir);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.log("Error loading migrations", error);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (fileNames.length === 0)
|
|
76
|
+
console.log("No migrations found in ./migrations");
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
for (const migrationName of fileNames.sort((a, b) => {
|
|
79
|
+
const migrationNumberA = parseInt(a.split("_")[0]!);
|
|
80
|
+
const migrationNumberB = parseInt(b.split("_")[0]!);
|
|
81
|
+
if (migrationNumberA < migrationNumberB) {
|
|
82
|
+
return -1;
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
if (migrationNumberA > migrationNumberB) {
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// numbers must be equal
|
|
89
|
+
return 0;
|
|
90
|
+
})) {
|
|
83
91
|
const migrationPath = path.join(migrationsDir, migrationName);
|
|
84
92
|
let migration = await nodefs.readFile(migrationPath, "utf8");
|
|
85
93
|
// Remove migration comment
|