1.0.3 • Published 3 years ago

yarn-add-cmd-maker v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Introduction

a helper function that will output the "yarn add <...packages> " for you

Source Code

module.exports.maker = function(){

    var fs = require("fs");
    var str = fs.readFileSync("./package.json").toString('utf-8');

    if(str==null){
        throw new Error("package.json not found or no ");
    }

    const obj = JSON.parse(str)


    let dependencies = Object.keys(obj.dependencies)

    if(obj.dependencies!=null){

        var myString1 = dependencies.join(' ');

        command1 = "yarn add " + myString1;

        console.log(command1);

    }
    if(obj.devDependencies!=null){

    let devDependencies = Object.keys(obj.devDependencies)


        var myString2 = devDependencies.join(' ');

        command2 = "yarn add " + myString2 + " --dev";

        console.log(command2);

    }

}

Usage

var { maker } = require('yarn-add-cmd-maker')

maker(); // this will do the job

the function will open the package.json file on the same directory output the yarn install command as a string with the dependencies specified in the package.json file

Returns: Returns "yarn add <...packages specified in package.json file>"

Installation

npm install yarn-add-cmd-maker
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago