-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert from cjs to esm (#134)
* chore: convert from cjs to esm * chore(test): convert from cjs to esm * chore(cd): convert sdk script from cjs to esm * fix: assert json type * fix: export findpath * fix: __dirname workaround
- Loading branch information
1 parent
d24e926
commit 0f0453e
Showing
9 changed files
with
74 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const fs = require('node:fs'); | ||
import { writeFileSync } from 'node:fs'; | ||
|
||
const nodeManifest = require('../package.json'); | ||
import nodeManifest from '../package.json' assert { type: 'json' }; | ||
|
||
nodeManifest.version = nodeManifest.version + '-sdk'; | ||
|
||
fs.writeFileSync('./package.json', JSON.stringify(nodeManifest, null, 2)); | ||
writeFileSync('./package.json', JSON.stringify(nodeManifest, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var argv = require('yargs').argv; | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { join, basename } from 'path'; | ||
import { argv } from 'yargs'; | ||
|
||
// Helper to simulate the shell's "cp" command | ||
function copyFileSync(srcFile, destFile) { | ||
var content = fs.readFileSync(srcFile); | ||
fs.writeFileSync(destFile, content); | ||
var content = readFileSync(srcFile); | ||
writeFileSync(destFile, content); | ||
} | ||
|
||
// Copy asset files (specified via process.argv) over to the app binary's folder | ||
exports.copyAssets = function copyAssets(platform, binPath) { | ||
export function copyAssets(platform, binPath) { | ||
// OS X: Save a custom plist file to Contents/Info.plist in the | ||
// app bundle. This lets you customize things like the app's menubar | ||
// name and icon (see argv.mac_icon below) | ||
if (argv.mac_plist && platform === 'darwin') { | ||
var plistPath = path.join(binPath, '..', '..', 'Info.plist'); | ||
var plistPath = join(binPath, '..', '..', 'Info.plist'); | ||
copyFileSync(argv.mac_plist, plistPath); | ||
} | ||
|
||
// OS X: Save icon files to the Resources dir in the app bundle. | ||
// Note that for the icon to work properly you need to point to | ||
// it with a custom plist file. | ||
if (argv.mac_icon && platform === 'darwin') { | ||
var iconName = path.basename(argv.mac_icon); // Preserve the file's name | ||
var iconPath = path.join(binPath, '..', '..', 'Resources', iconName); | ||
var iconName = basename(argv.mac_icon); // Preserve the file's name | ||
var iconPath = join(binPath, '..', '..', 'Resources', iconName); | ||
copyFileSync(argv.mac_icon, iconPath); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters