Skip to content

Commit

Permalink
refactor: Ensure constient returns
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 15, 2020
1 parent 370c097 commit d5833f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/classes/Utils.js
Expand Up @@ -45,11 +45,11 @@ class Utils {
}

writeFileDir(filePath) {
return fse.mkdirsSync(path.dirname(filePath));
fse.mkdirsSync(path.dirname(filePath));
}

writeFileSync(filePath, contents, cycles) {
return writeFileSync(filePath, contents, cycles);
writeFileSync(filePath, contents, cycles);
}

writeFile(filePath, contents, cycles) {
Expand Down
12 changes: 4 additions & 8 deletions lib/classes/Utils.test.js
Expand Up @@ -62,15 +62,11 @@ describe('Utils', () => {
describe('#writeFileDir()', () => {
it('should create a directory for the path of the given file', () => {
const tmpDirPath = getTmpDirPath();
const rootDir = serverless.utils.writeFileDir(
path.join(tmpDirPath, 'foo', 'bar', 'somefile.js')
);

expect(serverless.utils.dirExistsSync(path.join(rootDir, 'foo', 'bar'))).to.equal(true);
const fileDir = path.join(tmpDirPath, 'foo', 'bar');
serverless.utils.writeFileDir(path.join(fileDir, 'somefile.js'));
expect(serverless.utils.dirExistsSync(fileDir)).to.equal(true);
// it should only create the directories and not the file
expect(
serverless.utils.fileExistsSync(path.join(rootDir, 'foo', 'bar', 'somefile.js'))
).to.equal(false);
expect(serverless.utils.fileExistsSync(path.join(fileDir, 'somefile.js'))).to.equal(false);
});
});

Expand Down

0 comments on commit d5833f8

Please sign in to comment.