From 8d595afeb7cf8db2be1664a12da80a5d65b22c42 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 10 Jun 2024 18:03:15 +0200 Subject: [PATCH] feat: adding npm start to package.json --- src/init.js | 3 ++- tests/init.test.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/init.js b/src/init.js index 4f876e6..137a103 100644 --- a/src/init.js +++ b/src/init.js @@ -31,12 +31,13 @@ const init = async (destination_folder) => { // append to package.json let packageJson = JSON.parse(fs.readFileSync("package.json")); packageJson.scripts["postinstall"] = "webrcli installFromPackageJson"; + packageJson.scripts["start"] = "node index.js"; fs.writeFileSync("package.json", JSON.stringify(packageJson, null, 2)); process.chdir(previousDirectory); // copying template - log("💀 Copying project skeleton ----"); + log("🗂️ Copying project skeleton ----"); fs.cpSync( path.join(__dirname, "..", "template"), path.join(destination_folder), diff --git a/tests/init.test.js b/tests/init.test.js index 1e04669..15b5425 100644 --- a/tests/init.test.js +++ b/tests/init.test.js @@ -1,4 +1,5 @@ const {init} = require('../src/init'); +const { parsePackageJson } = require('../src/packagejsonmanip'); const path = require('path'); const os = require('os'); @@ -31,6 +32,16 @@ test('init works', async () => { ) ).toBe(true); + let packageJson = parsePackageJson(path.join(temp_dir, 'package.json')); + + expect( + packageJson.scripts.postinstall + ).toBe('webrcli installFromPackageJson'); + + expect( + packageJson.scripts.start + ).toBe('node index.js'); + expect( fs.existsSync( path.join(temp_dir, 'webr_packages')