Skip to content

Commit

Permalink
feat: adding npm start to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay committed Jun 10, 2024
1 parent c22f8d9 commit 8d595af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
11 changes: 11 additions & 0 deletions tests/init.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {init} = require('../src/init');
const { parsePackageJson } = require('../src/packagejsonmanip');

const path = require('path');
const os = require('os');
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 8d595af

Please sign in to comment.