mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
make sure the integration set suite works cross-platform (not depedent on gnu sed)
This commit is contained in:
parent
e6d838dceb
commit
b994ffe82f
@ -29,8 +29,8 @@ describe('Service Lifecyle Integration Test', function () {
|
||||
|
||||
it('should create service in tmp directory', () => {
|
||||
execSync(`${serverlessExec} create --template ${templateName}`, { stdio: 'inherit' });
|
||||
execSync(`sed -i.bak s/${templateName}/${newServiceName}/g serverless.yml`);
|
||||
execSync("sed -i.bak '/provider:/a \\ cfLogs: true' serverless.yml");
|
||||
testUtils.replaceTextInFile('serverless.yml', templateName, newServiceName);
|
||||
testUtils.replaceTextInFile('serverless.yml', 'name: aws', 'name: aws\n cfLogs: true');
|
||||
expect(serverless.utils
|
||||
.fileExistsSync(path.join(tmpDir, 'serverless.yml'))).to.be.equal(true);
|
||||
expect(serverless.utils
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
@ -18,10 +19,16 @@ const getTmpDirPath = () => path.join(os.tmpdir(),
|
||||
|
||||
const getTmpFilePath = (fileName) => path.join(getTmpDirPath(), fileName);
|
||||
|
||||
const replaceTextInFile = (filePath, subString, newSubString) => {
|
||||
const fileContent = fs.readFileSync(filePath).toString();
|
||||
fs.writeFileSync(filePath, fileContent.replace(subString, newSubString));
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
serverlessExec,
|
||||
getTmpDirPath,
|
||||
getTmpFilePath,
|
||||
replaceTextInFile,
|
||||
|
||||
createTestService: (templateName, testServiceDir) => {
|
||||
const serviceName = `service-${(new Date()).getTime().toString()}`;
|
||||
@ -40,6 +47,7 @@ module.exports = {
|
||||
fse.copySync(testServiceDir, tmpDir, { clobber: true, preserveTimestamps: true });
|
||||
}
|
||||
|
||||
replaceTextInFile('serverless.yml', templateName, serviceName);
|
||||
execSync(`sed -i.bak s/${templateName}/${serviceName}/g serverless.yml`);
|
||||
|
||||
process.env.TOPIC_1 = `${serviceName}-1`;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user