Skip to content

Commit bceb737

Browse files
authored
fix: Use absolute paths to ensure compatibility with v4 Compose (#854)
1 parent 57f7c6b commit bceb737

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

.github/workflows/validate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: python -m pip install --force setuptools wheel
6262

6363
- name: Install pipenv / poetry
64-
run: python -m pip install pipenv poetry
64+
run: python -m pip install pipenv poetry && poetry self add poetry-plugin-export
6565

6666
- name: Install serverless
6767
run: npm install -g serverless@${{ matrix.sls-version }}

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ServerlessPythonRequirements {
7474
options.pythonBin = 'python';
7575
}
7676
if (/python3[0-9]+/.test(options.pythonBin)) {
77-
// "google" and "scaleway" providers' runtimes uses python3XX
77+
// "google" and "scaleway" providers' runtimes use python3XX
7878
options.pythonBin = options.pythonBin.replace(/3([0-9]+)/, '3.$1');
7979
}
8080
if (options.dockerizePip === 'non-linux') {

lib/inject.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,20 @@ async function injectAllRequirements(funcArtifact) {
153153
return this.options.zip
154154
? func
155155
: injectRequirements(
156-
path.join('.serverless', func.module, 'requirements'),
156+
path.join(
157+
this.serverless.serviceDir,
158+
'.serverless',
159+
func.module,
160+
'requirements'
161+
),
157162
func.package.artifact,
158163
injectionRelativePath,
159164
this.options
160165
);
161166
});
162167
} else if (!this.options.zip) {
163168
await injectRequirements(
164-
path.join('.serverless', 'requirements'),
169+
path.join(this.serverless.serviceDir, '.serverless', 'requirements'),
165170
this.serverless.service.package.artifact || funcArtifact,
166171
injectionRelativePath,
167172
this.options

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@
7777
"sha256-file": "1.0.0",
7878
"shell-quote": "^1.8.1"
7979
},
80-
"peerDependencies": {
81-
"serverless": ">=2.32"
82-
},
8380
"lint-staged": {
8481
"*.js": [
8582
"eslint"

test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ test(
206206
process.chdir('tests/base');
207207
const { stdout: path } = npm(['pack', '../..']);
208208
npm(['i', path]);
209-
const { stderr } = sls(['package'], {
209+
const { stdout } = sls(['package'], {
210210
noThrow: true,
211211
env: {
212212
dockerizePip: true,
@@ -216,7 +216,7 @@ test(
216216
},
217217
});
218218
t.true(
219-
stderr.includes(
219+
stdout.includes(
220220
`-v ${__dirname}${sep}tests${sep}base${sep}custom_ssh:/root/.ssh/custom_ssh:z`
221221
),
222222
'docker command properly resolved'
@@ -1742,12 +1742,12 @@ test('poetry py3.9 fails packaging if poetry.lock is missing and flag requirePoe
17421742

17431743
const { stdout: path } = npm(['pack', '../..']);
17441744
npm(['i', path]);
1745-
const { stderr } = sls(['package'], {
1745+
const { stdout } = sls(['package'], {
17461746
env: { requirePoetryLockFile: 'true', slim: 'true' },
17471747
noThrow: true,
17481748
});
17491749
t.true(
1750-
stderr.includes(
1750+
stdout.includes(
17511751
'poetry.lock file not found - set requirePoetryLockFile to false to disable this error'
17521752
),
17531753
'flag works and error is properly reported'

0 commit comments

Comments
 (0)