-1

I want to create vs code task which create folder of given name and , below is the definition of task, it is working fine

here is my task

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "node file",
      "detail": "Create file from node",
      "type": "shell",
      "command": "node ./.vscode/hello.js",
      "presentation": {
        "reveal": "silent",
        "panel": "shared"
      },
      "args": ["${input:name}"],
      "problemMatcher": []
    }
  ],
  "inputs": [
    {
      "id": "name",
      "description": "Name your file",
      "default": "new-file",
      "type": "promptString"
    }
  ]
}

.vscode/hello.js

import fs from "fs";

fs.writeFile("filename.html", "HTML content", function (err) {
  if (err) throw err;
  console.log("Saved!");
});

but problem is how to send input into the script file hello.js so that it create that file name with content.

how can we achive this?

Refrence: Tasks in vs code

xkeshav
  • 53,360
  • 44
  • 177
  • 245
  • Does this answer your question? [How do I pass command line arguments to a Node.js program and receive them?](https://stackoverflow.com/questions/4351521/how-do-i-pass-command-line-arguments-to-a-node-js-program-and-receive-them) – starball Aug 25 '23 at 21:04

0 Answers0