forked from cory/tildefriends
Make app export append a trailing newline to the app.json files so that we match prettier.
This commit is contained in:
parent
d5267be38c
commit
70a3e7fc7d
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "💽"
|
"emoji": "💽"
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void _write_file(const char* path, const void* blob, size_t size)
|
static void _write_file(const char* path, const void* blob, size_t size, bool force_add_trailing_newline)
|
||||||
{
|
{
|
||||||
FILE* file = fopen(path, "wb");
|
FILE* file = fopen(path, "wb");
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
fwrite(blob, 1, size, file);
|
fwrite(blob, 1, size, file);
|
||||||
|
if (force_add_trailing_newline)
|
||||||
|
{
|
||||||
|
fputc('\n', file);
|
||||||
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -147,7 +151,7 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key)
|
|||||||
if (tf_ssb_db_blob_get(ssb, blob_id, &file_blob, &file_size))
|
if (tf_ssb_db_blob_get(ssb, blob_id, &file_blob, &file_size))
|
||||||
{
|
{
|
||||||
snprintf(file_path, sizeof(file_path), "apps/%s/%s", path, file_name);
|
snprintf(file_path, sizeof(file_path), "apps/%s/%s", path, file_name);
|
||||||
_write_file(file_path, file_blob, file_size);
|
_write_file(file_path, file_blob, file_size, false);
|
||||||
tf_free(file_blob);
|
tf_free(file_blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +181,7 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key)
|
|||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
const char* string = JS_ToCStringLen(context, &length, json);
|
const char* string = JS_ToCStringLen(context, &length, json);
|
||||||
snprintf(file_path, sizeof(file_path), "apps/%s.json", path);
|
snprintf(file_path, sizeof(file_path), "apps/%s.json", path);
|
||||||
_write_file(file_path, string, length);
|
_write_file(file_path, string, length, true);
|
||||||
JS_FreeCString(context, string);
|
JS_FreeCString(context, string);
|
||||||
JS_FreeValue(context, json);
|
JS_FreeValue(context, json);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user