Skip to content

Commit d193da3

Browse files
committed
Back to CJS
1 parent 415dd29 commit d193da3

8 files changed

+1989
-1246
lines changed

dist/index.js

Lines changed: 1972 additions & 993 deletions
Large diffs are not rendered by default.

dist/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/pull-google-sheets-to-json.js

Lines changed: 0 additions & 104 deletions
This file was deleted.

dist/push-json-to-google-sheets.js

Lines changed: 0 additions & 128 deletions
This file was deleted.

entrypoint.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import core from '@actions/core';
2-
import fs from 'fs';
3-
import path from 'path';
4-
import { main as pushMain } from './scripts/push-json-to-google-sheets.js';
5-
import { fetchSheetData as pullMain } from './scripts/pull-google-sheets-to-json.js';
1+
const core = require('@actions/core');
2+
const fs = require('fs');
3+
const path = require('path');
4+
const { main: pushMain } = require('./scripts/push-json-to-google-sheets');
5+
const { fetchSheetData: pullMain } = require('./scripts/pull-google-sheets-to-json');
66

77
// Get inputs
88
const action = core.getInput('action');
@@ -49,9 +49,9 @@ process.env.LOCALIZATION_ROOT = localizationRoot;
4949

5050
try {
5151
if (action === 'push') {
52-
await pushMain();
52+
pushMain();
5353
} else if (action === 'pull') {
54-
await pullMain();
54+
pullMain();
5555
} else {
5656
core.setFailed(`Unknown action: ${action}`);
5757
process.exit(1);

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "abp-localization-sync",
33
"version": "1.0.1",
44
"description": "GitHub Action to sync localization data with Google Sheets",
5-
"type": "module",
65
"main": "dist/index.js",
76
"dependencies": {
87
"@actions/core": "^1.11.1",

scripts/pull-google-sheets-to-json.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { google } from 'googleapis';
2-
import fs from 'fs';
3-
import path from 'path';
1+
const { google } = require('googleapis');
2+
const fs = require('fs');
3+
const path = require('path');
44

55
const processSheet = async (sheetName, rows, localizationRoot) => {
66
if (!rows || rows.length === 0) {
@@ -97,8 +97,8 @@ const fetchSheetData = async () => {
9797
console.log('Data successfully pulled and JSON files updated');
9898
};
9999

100-
if (import.meta.url === `file://${process.argv[1]}`) {
100+
if (require.main === module) {
101101
fetchSheetData();
102102
}
103103

104-
export { processSheet, fetchSheetData };
104+
module.exports = { processSheet, fetchSheetData };

scripts/push-json-to-google-sheets.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { google } from 'googleapis';
2-
import fs from 'fs';
3-
import path from 'path';
1+
const { google } = require('googleapis');
2+
const fs = require('fs');
3+
const path = require('path');
44

55
const parseLocalizationFiles = (folderPath) => {
66
const files = fs.readdirSync(folderPath).filter(file => file.endsWith('.json'));
@@ -121,8 +121,8 @@ const main = async () => {
121121
console.log('Data successfully uploaded to Google Sheets');
122122
};
123123

124-
if (import.meta.url === `file://${process.argv[1]}`) {
124+
if (require.main === module) {
125125
main();
126126
}
127127

128-
export { processFolder, parseLocalizationFiles, main };
128+
module.exports = { processFolder, parseLocalizationFiles, main };

0 commit comments

Comments
 (0)