Skip to content

Commit 9b9501b

Browse files
chore: correct eslint errors
1 parent 5ba665b commit 9b9501b

File tree

2 files changed

+75
-78
lines changed

2 files changed

+75
-78
lines changed

addon/ng2/utilities/barrel-management.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ var EOL = require('os').EOL;
55
module.exports = addBarrelRegistration;
66

77
function sortBarrel(contents) {
8-
var parts = contents.split(EOL).filter(function(l){
9-
return l.trim().length > 0;
10-
});
11-
parts.sort();
12-
return parts.join(EOL) + EOL;
8+
var parts = contents.split(EOL).filter(function(l){
9+
return l.trim().length > 0;
10+
});
11+
parts.sort();
12+
return parts.join(EOL) + EOL;
1313
}
1414

1515
function addBarrelRegistration(blueprint, installationDir, fileName) {

tests/acceptance/barrel-management.spec.js

+70-73
Original file line numberDiff line numberDiff line change
@@ -13,160 +13,157 @@ describe('barrel-management', () => {
1313
var blueprint;
1414
var installationDirectory;
1515

16-
beforeEach(() => {
17-
blueprint = new Blueprint('/');
18-
blueprint.project = {
19-
root: '/'
20-
}
21-
});
16+
beforeEach(() => {
17+
blueprint = new Blueprint('/');
18+
blueprint.project = {
19+
root: '/'
20+
}
21+
});
2222

2323
describe('when not shared', () => {
2424

2525

2626
beforeEach(() => {
27-
var rootName = path.parse(process.cwd());
27+
var mockDrive = {
28+
'/src/app/my-component': {}
29+
};
30+
mockFs(mockDrive);
2831

29-
var mockFolder = {};
30-
var mockDrive = {
31-
'/src/app/my-component' : {}
32-
};
33-
mockFs(mockFolder);
34-
35-
installationDirectory = path.join('src', 'app', 'my-component');
32+
installationDirectory = path.join('src', 'app', 'my-component');
3633
});
3734

3835
afterEach(() => {
39-
mockFs.restore();
36+
mockFs.restore();
4037
});
4138

42-
it('should do nothing', () => {
43-
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
39+
it('should do nothing', () => {
40+
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
4441
var barrelPath = path.join(installationDirectory, 'index.ts');
4542
expect(existsSync(barrelPath)).to.equal(false);
46-
});
47-
});
43+
});
44+
});
4845
});
4946

5047
describe('no pre-existing barrel', () => {
5148

5249
beforeEach(() => {
53-
var mockDrive = {
54-
'/src/app/shared/my-component' : {}
55-
};
56-
mockFs(mockDrive);
50+
var mockDrive = {
51+
'/src/app/shared/my-component': {}
52+
};
53+
mockFs(mockDrive);
5754

58-
installationDirectory = path.join('/src/app/shared/my-component');
55+
installationDirectory = path.join('/src/app/shared/my-component');
5956
});
6057

6158
afterEach(() => {
62-
mockFs.restore();
59+
mockFs.restore();
6360
});
6461

65-
it('create barrel from installation dir', () => {
66-
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
67-
var fs = require('fs');
62+
it('create barrel from installation dir', () => {
63+
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
64+
var fs = require('fs');
6865
var barrelPath = path.join(installationDirectory, '..', 'index.ts');
6966
expect(existsSync(barrelPath)).to.equal(true);
7067
var contents = fs.readFileSync(barrelPath, 'utf8');
7168
var expectedContents = `export * from './my-component';${EOL}`;
7269
expect(contents).to.equal(expectedContents);
73-
});
74-
});
70+
});
71+
});
7572

76-
it('create barrel from installation dir with file name', () => {
77-
return addBarrelRegistration(blueprint, installationDirectory, 'my-smaller-component').then(() => {
78-
var fs = require('fs');
73+
it('create barrel from installation dir with file name', () => {
74+
return addBarrelRegistration(blueprint, installationDirectory, 'my-smaller-component').then(() => {
75+
var fs = require('fs');
7976
var barrelPath = path.join(installationDirectory, '..', 'index.ts');
8077
expect(existsSync(barrelPath)).to.equal(true);
8178
var contents = fs.readFileSync(barrelPath, 'utf8');
8279
var expectedContents = `export * from './my-component/my-smaller-component';${EOL}`;
8380
expect(contents).to.equal(expectedContents);
84-
});
85-
});
81+
});
82+
});
8683

8784
});
8885

8986
describe('pre-existing barrel', () => {
9087

9188
beforeEach(() => {
92-
var mockDrive = {
93-
'/src/app/shared' : {
94-
'my-component': {},
95-
'index.ts': `export * from './another-component${EOL}export * from './other-component${EOL}`
96-
}
97-
};
98-
mockFs(mockDrive);
89+
var mockDrive = {
90+
'/src/app/shared': {
91+
'my-component': {},
92+
'index.ts': `export * from './another-component${EOL}export * from './other-component${EOL}`
93+
}
94+
};
95+
mockFs(mockDrive);
9996

100-
installationDirectory = path.join('/src/app/shared/my-component');
97+
installationDirectory = path.join('/src/app/shared/my-component');
10198
});
10299

103100
afterEach(() => {
104-
mockFs.restore();
101+
mockFs.restore();
105102
});
106103

107-
it('update barrel from installation dir', () => {
108-
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
109-
var fs = require('fs');
104+
it('update barrel from installation dir', () => {
105+
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
106+
var fs = require('fs');
110107
var barrelPath = path.join(installationDirectory, '..', 'index.ts');
111108
expect(existsSync(barrelPath)).to.equal(true);
112109
var contents = fs.readFileSync(barrelPath, 'utf8');
113110
var expectedContents = `export * from './another-component${EOL}export * from './my-component';${EOL}export * from './other-component${EOL}`;
114111
expect(contents).to.equal(expectedContents);
115-
});
116-
});
112+
});
113+
});
117114

118-
it('updateA barrel from installation dir with file name', () => {
119-
return addBarrelRegistration(blueprint, installationDirectory, 'my-smaller-component').then(() => {
120-
var fs = require('fs');
115+
it('updateA barrel from installation dir with file name', () => {
116+
return addBarrelRegistration(blueprint, installationDirectory, 'my-smaller-component').then(() => {
117+
var fs = require('fs');
121118
var barrelPath = path.join(installationDirectory, '..', 'index.ts');
122119
expect(existsSync(barrelPath)).to.equal(true);
123120
var contents = fs.readFileSync(barrelPath, 'utf8');
124121
var expectedContents = `export * from './another-component${EOL}export * from './my-component/my-smaller-component';${EOL}export * from './other-component${EOL}`;
125122
expect(contents).to.equal(expectedContents);
126-
});
127-
});
123+
});
124+
});
128125

129126
});
130127

131128
describe('pre-existing barrel with export already defined', () => {
132129

133130
beforeEach(() => {
134-
var mockDrive = {
135-
'/src/app/shared' : {
136-
'my-component': {},
137-
'index.ts': `export * from './other-component${EOL}export * from './my-component';${EOL}export * from './another-component${EOL}export * from './my-component/my-smaller-component';${EOL}`
138-
}
139-
};
140-
mockFs(mockDrive);
131+
var mockDrive = {
132+
'/src/app/shared': {
133+
'my-component': {},
134+
'index.ts': `export * from './other-component${EOL}export * from './my-component';${EOL}export * from './another-component${EOL}export * from './my-component/my-smaller-component';${EOL}`
135+
}
136+
};
137+
mockFs(mockDrive);
141138

142-
installationDirectory = path.join('/src/app/shared/my-component');
139+
installationDirectory = path.join('/src/app/shared/my-component');
143140
});
144141

145142
afterEach(() => {
146-
mockFs.restore();
143+
mockFs.restore();
147144
});
148145

149-
it('update barrel from installation dir should add nothing', () => {
150-
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
151-
var fs = require('fs');
146+
it('update barrel from installation dir should add nothing', () => {
147+
return addBarrelRegistration(blueprint, installationDirectory).then(() => {
148+
var fs = require('fs');
152149
var barrelPath = path.join(installationDirectory, '..', 'index.ts');
153150
expect(existsSync(barrelPath)).to.equal(true);
154151
var contents = fs.readFileSync(barrelPath, 'utf8');
155152
var expectedContents = `export * from './another-component${EOL}export * from './my-component';${EOL}export * from './my-component/my-smaller-component';${EOL}export * from './other-component${EOL}`;
156153
expect(contents).to.equal(expectedContents);
157-
});
158-
});
154+
});
155+
});
159156

160-
it('update barrel from installation dir with file name should add nothing', () => {
161-
return addBarrelRegistration(blueprint, installationDirectory, 'my-smaller-component').then(() => {
162-
var fs = require('fs');
157+
it('update barrel from installation dir with file name should add nothing', () => {
158+
return addBarrelRegistration(blueprint, installationDirectory, 'my-smaller-component').then(() => {
159+
var fs = require('fs');
163160
var barrelPath = path.join(installationDirectory, '..', 'index.ts');
164161
expect(existsSync(barrelPath)).to.equal(true);
165162
var contents = fs.readFileSync(barrelPath, 'utf8');
166163
var expectedContents = `export * from './another-component${EOL}export * from './my-component';${EOL}export * from './my-component/my-smaller-component';${EOL}export * from './other-component${EOL}`;
167164
expect(contents).to.equal(expectedContents);
168-
});
169-
});
165+
});
166+
});
170167

171168
});
172169
});

0 commit comments

Comments
 (0)