How to source a js script file using collections sdk

Hi

I am trying to use a separate script file using your collection sdk.

In the docs, it says you can reference the file location using src and point it relative to the script.

Every variation I have tried has failed so far though:

ā€™script.jsā€™

ā€™/script.jsā€™

ā€™./script.jsā€™

If I use exec , it works fine though i.e when I open up postman and edit the folder, I can see my code where I want it (in the folder).

MY COLLECTION.JS:

// variables

var fs = require("fs"), // for IO

Collection = require(ā€˜postman-collectionā€™).Collection,

Item = require(ā€˜postman-collectionā€™).Item,

ItemGroup = require(ā€˜postman-collectionā€™).ItemGroup,

Script = require(ā€˜postman-collectionā€™).Script,

myCollection,

myScript;

// create the collection

myCollection = new Collection({

"name": "collection",

"id": "collection",

});

// add the folder

myCollection.items.add(new ItemGroup({

"id": "folder",

"name": "folder"

}));

// add requests to the search folder

myCollection.items.one("folder").items.add(new Item({

"name": "request",

"id": "request",

"request": {

"url": "https://postman-echo.com/",

"method": "GET"

}

}));

// add scripts to the search folder

myScript = new Script();

myScript.update({

// exec: 'console.log(ā€œinlineā€)'

src: './script.jsā€™

});

myCollection.items.one("folder").events.add({

listen: "test",

script: myScript

});

// export the collection

fs.writeFileSync("collection.postman_collection.json", JSON.stringify(myCollection, null, 2));

MY SCRIPT.JS (IN SAME FOLDER AS COLLECTION.JS):

console.log(ā€˜from fileā€™);

So my question basically is: how can I point to a separate file to bring in my js code?

I am wondering if I need to use fs somehow to read the file in?

Any help would be greatly appreciated.

Thanks

Leon

Hi , I am encountering a similar issue.Did anyone find a solution to this problem?