Skip to content

Commit

Permalink
porting to use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
pwsimon authored and vraravam committed Feb 28, 2024
1 parent 4ab81dc commit 912f563
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"prepare": "is-ci || husky install",
"validate": "pnpm lint:fix && pnpm reformat-files && pnpm package",
"package": "node scripts/package.js",
"create": "node scripts/create.js",
"create": "node scripts/create.mjs",
"lint": "eslint \"{recipes,scripts}/**/*.{js,jsx,ts,tsx}\"",
"lint:fix": "pnpm lint --fix",
"reformat-files": "prettier --ignore-path .eslintignore --write \"**/*.{js,json,scss}\"",
Expand Down
9 changes: 5 additions & 4 deletions scripts/create.js → scripts/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
/**
* Create a new recipe for your service
*/
const fs = require('fs-extra');
const path = require('path');
const open = require('open');
import fs from 'fs-extra';

import path from 'path';
import open from 'open';

if (process.argv.length < 3) {
console.log(`Usage: pnpm create <Recipe name> [Folder name]
Expand Down Expand Up @@ -49,7 +50,7 @@ const pascalCasedName = toPascalCase(recipe); // PascalCased recipe ID only cont
const recipesFolder = path.join(userData, folderName, 'recipes');
const devRecipeFolder = path.join(recipesFolder, 'dev');
const newRecipeFolder = path.join(devRecipeFolder, recipe);
const sampleRecipe = path.join(__dirname, 'sample_recipe');
const sampleRecipe = path.join(import.meta.dirname, 'sample_recipe'); // Starting with Node.js 20.11 / 21.2, you can use import.meta.dirname

// Make sure dev recipe folder exists
if (!fs.existsSync(recipesFolder)) {
Expand Down

0 comments on commit 912f563

Please sign in to comment.