Skip to content

Commit 528e9db

Browse files
author
Waldemar Zurowski
committed
packageFileName is a proper closure
1 parent e84ec37 commit 528e9db

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/files.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,26 @@ const path = require('path');
44

55
module.exports = {
66
serviceFile: function (root, pkg) {
7-
return path.resolve(root, packageFileName(pkg) + '.service');
7+
return path.resolve(root, this.packageFileName(pkg) + '.service');
88
},
99
specsDirectory: function (root) {
1010
return path.resolve(root, 'SPECS');
1111
},
1212
specFile: function (root, pkg) {
13-
return path.resolve(root, packageFileName(pkg) + '.spec');
13+
return path.resolve(root, this.packageFileName(pkg) + '.spec');
1414
},
1515
sourcesDirectory: function (root) {
1616
return path.resolve(root, 'SOURCES');
1717
},
1818
sourcesArchive: function (root, pkg) {
1919
const sourcesDirectory = this.sourcesDirectory(root);
2020

21-
return path.resolve(sourcesDirectory, packageFileName(pkg) + '.tar.gz');
21+
return path.resolve(sourcesDirectory, this.packageFileName(pkg) + '.tar.gz');
2222
},
23-
packageFileName: packageFileName
23+
packageFileName: function (pkg) {
24+
return pkg.name[0] === '@'
25+
// scoped packages get special treatment
26+
? pkg.name.substr(1).replace(/\//g, '-')
27+
: pkg.name;
28+
}
2429
};
25-
26-
function packageFileName (pkg) {
27-
return pkg.name[0] === '@'
28-
// scoped packages get special treatment
29-
? pkg.name.substr(1).replace(/\//g, '-')
30-
: pkg.name;
31-
}

0 commit comments

Comments
 (0)