Skip to content

Commit

Permalink
fix(deps): unnamed function
Browse files Browse the repository at this point in the history
fix #668
  • Loading branch information
vogloblinsky committed Oct 12, 2018
1 parent c732330 commit a8881b4
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 46 deletions.
128 changes: 83 additions & 45 deletions src/app/application.ts
Expand Up @@ -2528,56 +2528,84 @@ at least one config for the 'info' or 'source' tab in --navTabConfig.`);
if (errorCopy) {
logger.error('Error during resources copy ', errorCopy);
} else {
if (this.configuration.mainData.extTheme) {
fs.copy(
path.resolve(
process.cwd() + path.sep + this.configuration.mainData.extTheme
),
path.resolve(finalOutput + '/styles/'),
function(errorCopyTheme) {
if (errorCopyTheme) {
logger.error(
'Error during external styling theme copy ',
errorCopyTheme
);
} else {
logger.info('External styling theme copy succeeded');
onComplete();
}

const extThemePromise = new Promise(
(extThemeResolve, extThemeReject) => {
if (this.configuration.mainData.extTheme) {
fs.copy(
path.resolve(
process.cwd() +
path.sep +
this.configuration.mainData.extTheme
),
path.resolve(finalOutput + '/styles/'),
function(errorCopyTheme) {
if (errorCopyTheme) {
logger.error(
'Error during external styling theme copy ',
errorCopyTheme
);
extThemeReject();
} else {
logger.info(
'External styling theme copy succeeded'
);
extThemeResolve();
}
}
);
} else {
extThemeResolve();
}
);
} else {
if (this.configuration.mainData.customFavicon !== '') {
logger.info(`Custom favicon supplied`);
fs.copy(
path.resolve(
process.cwd() +
path.sep +
this.configuration.mainData.customFavicon
),
path.resolve(finalOutput + '/images/favicon.ico'),
errorCopyFavicon => {
// tslint:disable-line
if (errorCopyFavicon) {
logger.error(
'Error during resources copy of favicon',
errorCopyFavicon
);
} else {
onComplete();
}
);

const customFaviconPromise = new Promise(
(customFaviconResolve, customFaviconReject) => {
if (
this.configuration.mainData.customFavicon !== ''
) {
logger.info(`Custom favicon supplied`);
fs.copy(
path.resolve(
process.cwd() +
path.sep +
this.configuration.mainData
.customFavicon
),
path.resolve(
finalOutput + '/images/favicon.ico'
),
errorCopyFavicon => {
// tslint:disable-line
if (errorCopyFavicon) {
logger.error(
'Error during resources copy of favicon',
errorCopyFavicon
);
customFaviconReject();
} else {
logger.info(
'External custom favicon copy succeeded'
);
customFaviconResolve();
}
}
}
);
} else {
onComplete();
);
} else {
customFaviconResolve();
}
}
);

const customLogoPromise = new Promise((customLogoResolve, customLogoReject) => {
if (this.configuration.mainData.customLogo !== '') {
logger.info(`Custom logo supplied`);
fs.copy(
path.resolve(
process.cwd() +
path.sep +
this.configuration.mainData.customLogo
path.sep +
this.configuration.mainData.customLogo
),
path.resolve(finalOutput + '/images/logo.png'),
errorCopyLogo => {
Expand All @@ -2587,15 +2615,25 @@ at least one config for the 'info' or 'source' tab in --navTabConfig.`);
'Error during resources copy of logo',
errorCopyLogo
);
customLogoReject();
} else {
onComplete();
logger.info('External custom logo copy succeeded');
customLogoResolve();
}
}
);
} else {
onComplete();
customLogoResolve();
}
}
});

Promise.all([
extThemePromise,
customFaviconPromise,
customLogoPromise
]).then(() => {
onComplete();
});
}
}
);
Expand Down
3 changes: 2 additions & 1 deletion src/app/compiler/angular-dependencies.ts
Expand Up @@ -1046,8 +1046,9 @@ export class AngularDependencies extends FrameworkDependencies {
}

private visitFunctionDeclaration(method: ts.FunctionDeclaration) {
let methodName = method.name ? method.name.text : 'Unnamed function';
let result: any = {
name: method.name.text,
name: methodName,
args: method.parameters ? method.parameters.map(prop => this.visitArgument(prop)) : []
};
let jsdoctags = this.jsdocParserUtil.getJSDocs(method);
Expand Down
5 changes: 5 additions & 0 deletions test/src/cli/cli-generation-big-app.spec.ts
Expand Up @@ -725,4 +725,9 @@ describe('CLI simple generation - big app', () => {
let file = read(distFolder + '/components/AppComponent.html');
expect(file).to.contain('<code>openSomeDialog(model,');
});

it('correct support unnamed function', () => {
let file = read(distFolder + '/miscellaneous/functions.html');
expect(file).to.contain('Unnamed');
});
});
@@ -0,0 +1,14 @@
export default function(value) {
const hexTable = [];
for (let i = 0; i < 256; i++) {
hexTable[i] = (i <= 15 ? '0' : '') + i.toString(16);
}

const id = Object.keys(value.id).map(key => value.id[key]);

let hexString = '';
for (const el of id) {
hexString += hexTable[el];
}
return hexString;
}

0 comments on commit a8881b4

Please sign in to comment.