Skip to content

Commit

Permalink
Merge pull request keithwhor#302 from jasondecamp/migrationFixHiddenF…
Browse files Browse the repository at this point in the history
…iles

fix migrations to ignore hidden files in the migrations directory
  • Loading branch information
keithwhor authored Nov 2, 2016
2 parents c28ee94 + ac390ba commit 46d53ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/my/bootstrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,13 @@ class Bootstrapper {
let schema_ids = result.rows.map((v) => { return v.id; });

let migrations = fs.readdirSync(MIGRATION_PATH).map((v) => {
if(v.indexOf('.') === 0) return {};
return {
id: parseInt(v.substr(0, v.indexOf('__'))),
migration: new (require(process.cwd() + '/' + MIGRATION_PATH + '/' + v))(db)
};
});

migrations = migrations.filter((v) => {
return schema_ids.indexOf(v.id) === -1;
}).filter((v) => {
return v.id && schema_ids.indexOf(v.id) === -1;
});

if (migrations.length === 0) {
Expand Down Expand Up @@ -245,12 +244,13 @@ class Bootstrapper {
let schema_ids = result.rows.map((v) => { return v.id; });

let migrations = fs.readdirSync(MIGRATION_PATH).map((v) => {
if(v.indexOf('.') === 0) return {};
return {
id: parseInt(v.substr(0, v.indexOf('__'))),
migration: new (require(process.cwd() + '/' + MIGRATION_PATH + '/' + v))(db)
};
}).filter((v) => {
return schema_ids.indexOf(v.id) !== -1;
return v.id && schema_ids.indexOf(v.id) !== -1;
}).reverse();

if (migrations.length === 0) {
Expand Down
1 change: 1 addition & 0 deletions core/required/model_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ModelFactory {

return fs
.readdirSync(dir)
.filter(filename => filename.indexOf('.') !== 0)
.map(filename => require(`${process.cwd()}/app/models/${filename}`))

}
Expand Down

0 comments on commit 46d53ef

Please sign in to comment.