Coder Social home page Coder Social logo

Comments (3)

serg06 avatar serg06 commented on June 28, 2024 2

@luismir15 This is my script

# scripts/patch-serverless-offline-sqs.sh

root='.'  # Project root
lib="${root}/node_modules/serverless-offline-sqs/src/sqs.js"

if grep -q patched "$lib"; then
  echo sqs.js already patched
else
  echo sqs.js is missing the patch, applying...
  sed -i "s|const sqsEvent = new SQSEventDefinition|// patched\n    const {queueName} = this.options;\n\n    if (queueName) rawSqsEventDefinition.queueName = queueName;\n\n    const sqsEvent = new SQSEventDefinition|" "$lib"
  echo done
fi

And my package.json has this:

"scripts": {
  "postinstall": "bash scripts/patch-serverless-offline-sqs.sh"
}

from serverless-plugins.

luismir15 avatar luismir15 commented on June 28, 2024 1

@serg06 this guide has been very helpful, so thank you for that. Also, I wanted to ask: how would you apply the patch in a postintall script?

from serverless-plugins.

luismir15 avatar luismir15 commented on June 28, 2024 1

thanks @serg06! I wanted to point out that I was getting an error while running the script

sed: 1: "node_modules/serverless ...": extra characters at the end of n command

I'm in macos so the only work around was to add an empty string in the sed command
sed -i "" "s|const sqsEvent = new SQSEventDefinition|// patched\n const {queueName} = this.options;\n\n if (queueName) rawSqsEventDefinition.queueName = queueName;\n\n const sqsEvent = new SQSEventDefinition|" "$lib"

found the solution here: https://myshittycode.com/2014/07/24/os-x-sed-extra-characters-at-the-end-of-l-command-error/

from serverless-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.