Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processes all files as JavaScript #27

Open
lewismoten opened this issue May 29, 2024 · 0 comments · May be fixed by #33
Open

Processes all files as JavaScript #27

lewismoten opened this issue May 29, 2024 · 0 comments · May be fixed by #33

Comments

@lewismoten
Copy link

I renamed a migration file with a .txt extension to get the migration script to skip over it, but it was still processed as a JavaScript migration.

An easy work-around for me is to prefix the file name with an underscore _ instead so that it doesn't pass the timestamp length test. However, I don't recall seeing the error thrown about being an invalid file. I would have expected this to only parse javascript files with case-insensitive js cjs or mjs extensions.

The other day I tried associating SQL files in the same folder to get syntax highlighting and didn't realize what the issue was.
ie same name 1716831766170_create_function_uuid4.up.sql to keep it close to the migration script, and do a file.readSync on the sql file.

fileFunctions.readFolder(path, function (files) {
files.forEach(function (file) {
var timestamp_split = file.split("_", 1);
if (timestamp_split.length) {
var timestamp = parseInt(timestamp_split[0]);
if (Number.isInteger(timestamp) && timestamp.toString().length == 13 && timestamp > max_timestamp) {
file_paths.push({ timestamp : timestamp, file_path : file});
}
} else {
throw new Error('Invalid file ' + file);
}
});

@lewismoten lewismoten linked a pull request Jun 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant