mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
Fix knex migration require translation
Change-type: patch Closes: #1274 Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
a9b830e68c
commit
585bd80313
@ -1,9 +1,11 @@
|
||||
// knex migrations use dynamic requires which break with webpack.
|
||||
// This hack makes the migrations directory a constant so that at least we can use webpack contexts for the
|
||||
// require.
|
||||
module.exports = function (source) {
|
||||
module.exports = function(source) {
|
||||
return source
|
||||
.toString()
|
||||
.replace(/require\(_path2\.default\.join\(_?this\._absoluteConfigDir\(\), name\)\);/g, "require('./migrations/' + name);")
|
||||
.replace("require(directory + '/' + name);", "require('./migrations/' + name);")
|
||||
}
|
||||
.replace(
|
||||
'path.join(absoluteDir, migration.file)',
|
||||
`'./migrations/'+migration.file`,
|
||||
);
|
||||
};
|
||||
|
@ -97,10 +97,11 @@ module.exports = function(env) {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: new RegExp(
|
||||
_.escapeRegExp(path.join('knex', 'lib', 'migrate', 'index.js')) +
|
||||
'$',
|
||||
),
|
||||
include: [
|
||||
new RegExp(
|
||||
_.escapeRegExp(path.join('knex', 'lib', 'migrate', 'sources')),
|
||||
),
|
||||
],
|
||||
use: require.resolve('./hardcode-migrations'),
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user