anote-server-libs 0.11.3 → 0.11.4

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.
@@ -57,7 +57,7 @@ END`)
57
57
  if (migrations.find(migration => migration.state !== 0))
58
58
  process.exit(4);
59
59
  fs.readdir(migrationsPath, (_, files) => {
60
- const migrationsAvailable = files
60
+ let migrationsAvailable = files
61
61
  .filter(file => /[0-9]+\.sql/.test(file))
62
62
  .map(file => parseInt(file.split('.sql')[0], 10))
63
63
  .filter(file => file > 0)
@@ -73,15 +73,19 @@ END`)
73
73
  const minAvailableId = migrationsAvailable.length > 0 ? migrationsAvailable[0].id : 0;
74
74
  const maxAvailableId = migrationsAvailable.length > 0 ? migrationsAvailable[migrationsAvailable.length - 1].id : Infinity;
75
75
  migrations = migrations.filter(m => m.id >= minAvailableId && m.id <= maxAvailableId);
76
- if (onlyAboveOrEquals)
76
+ if (onlyAboveOrEquals) {
77
77
  migrations = migrations.filter(m => m.id >= onlyAboveOrEquals);
78
- if (onlyBelow)
78
+ migrationsAvailable = migrationsAvailable.filter(m => m.id >= onlyAboveOrEquals);
79
+ }
80
+ if (onlyBelow) {
79
81
  migrations = migrations.filter(m => m.id < onlyBelow);
82
+ migrationsAvailable = migrationsAvailable.filter(m => m.id < onlyBelow);
83
+ }
80
84
  if (migrationsAvailable.length === 0 && migrations.length === 0)
81
85
  process.exit(5);
82
86
  if (migrationsAvailable.length && migrationsAvailable.length !== (migrationsAvailable[migrationsAvailable.length - 1].id - migrationsAvailable[0].id + 1))
83
87
  process.exit(5);
84
- let highestCommon = onlyAboveOrEquals;
88
+ let highestCommon = 0;
85
89
  while (highestCommon < migrations.length && highestCommon < migrationsAvailable.length
86
90
  && migrations[highestCommon].hash === migrationsAvailable[highestCommon].hash)
87
91
  highestCommon++;
@@ -58,7 +58,7 @@ END`)])).then(() => {
58
58
  if(migrations.find(migration => migration.state !== 0)) process.exit(4); // Have to fix manually
59
59
  // Read the new ones
60
60
  fs.readdir(migrationsPath, (_, files) => {
61
- const migrationsAvailable = files
61
+ let migrationsAvailable = files
62
62
  .filter(file => /[0-9]+\.sql/.test(file))
63
63
  .map(file => parseInt(file.split('.sql')[0], 10))
64
64
  .filter(file => file > 0)
@@ -74,11 +74,11 @@ END`)])).then(() => {
74
74
  const minAvailableId = migrationsAvailable.length > 0 ? migrationsAvailable[0].id : 0;
75
75
  const maxAvailableId = migrationsAvailable.length > 0 ? migrationsAvailable[migrationsAvailable.length - 1].id : Infinity;
76
76
  migrations = migrations.filter(m => m.id >= minAvailableId && m.id <= maxAvailableId);
77
- if(onlyAboveOrEquals) migrations = migrations.filter(m => m.id >= onlyAboveOrEquals);
78
- if(onlyBelow) migrations = migrations.filter(m => m.id < onlyBelow);
77
+ if(onlyAboveOrEquals) { migrations = migrations.filter(m => m.id >= onlyAboveOrEquals); migrationsAvailable = migrationsAvailable.filter(m => m.id >= onlyAboveOrEquals); }
78
+ if(onlyBelow) { migrations = migrations.filter(m => m.id < onlyBelow); migrationsAvailable = migrationsAvailable.filter(m => m.id < onlyBelow); }
79
79
  if(migrationsAvailable.length === 0 && migrations.length === 0) process.exit(5);
80
80
  if(migrationsAvailable.length && migrationsAvailable.length !== (migrationsAvailable[migrationsAvailable.length - 1].id - migrationsAvailable[0].id + 1)) process.exit(5);
81
- let highestCommon = onlyAboveOrEquals;
81
+ let highestCommon = 0;
82
82
  while(highestCommon < migrations.length && highestCommon < migrationsAvailable.length
83
83
  && migrations[highestCommon].hash === migrationsAvailable[highestCommon].hash)
84
84
  highestCommon++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anote-server-libs",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "Helpers for express-TS servers",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",