Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_attachLoggerStream() {
ProjectUtils.attachLoggerStream(this._projectRoot, {
stream: {
write: chunk => {
if (chunk.tag !== 'device') {
return;
} else if (this._getCurrentOpenProjectId() !== this._projectId) {
// TODO: We should be confident that we are properly unsubscribing
// from the stream rather than doing a defensive check like this.
return;
}
this._handleDeviceLogs(chunk);
},
},
type: 'raw',
});
}
newLogChunks.forEach(chunk => {
if (chunk.msg === 'Restarted watchman.') {
progressBar.tick(100 - progressBar.curr)
log.setBundleProgressBar(null)
progressBar = null
log.withTimestamp(chalk.red('Failed building JavaScript bundle'))
}
})
}
newLogChunks.map(handleLogChunk)
}
})
// Subscribe to device updates separately from packager/server updates
ProjectUtils.attachLoggerStream(projectDir, {
stream: {
write: chunk => {
if (chunk.tag === 'device') {
handleLogChunk(chunk)
}
}
},
type: 'raw'
})
installExitHooks(projectDir, isInteractive)
log.withTimestamp('Starting packager...')
Project.startAsync(projectDir, options).then(
() => {},
reason => {
startTime}ms.`
)
);
}
}
},
updateLogs: updater => {
let newLogChunks = updater([]);
newLogChunks.forEach(newLogChunk => {
logWithLevel(newLogChunk);
});
},
});
// needed for validation logging to function
ProjectUtils.attachLoggerStream(projectDir, {
stream: {
write: chunk => {
if (chunk.tag === 'device') {
logWithLevel(chunk);
}
},
},
type: 'raw',
});
// the existing CLI modules only pass one argument to this function, so skipProjectValidation
// will be undefined in most cases. we can explicitly pass a truthy value here to avoid validation (eg for init)
if (!skipProjectValidation) {
log('Making sure project is set up correctly...');
simpleSpinner.start();
// validate that this is a good projectDir before we try anything else
}
}
},
updateLogs: updater => {
let newLogChunks = updater([]);
newLogChunks.forEach(newLogChunk => {
if (newLogChunk.issueId && newLogChunk.issueCleared) {
return;
}
logWithLevel(newLogChunk);
});
},
});
// needed for validation logging to function
ProjectUtils.attachLoggerStream(projectDir, {
stream: {
write: chunk => {
if (chunk.tag === 'device') {
logWithLevel(chunk);
}
},
},
type: 'raw',
});
// The existing CLI modules only pass one argument to this function, so skipProjectValidation
// will be undefined in most cases. we can explicitly pass a truthy value here to avoid
// validation (eg for init)
//
// If the packager/manifest server is running and healthy, there is no need
// to rerun Doctor because the directory was already checked previously
newLogChunks.forEach(chunk => {
if (chunk.msg === 'Restarted watchman.') {
progressBar.tick(100 - progressBar.curr);
log.setBundleProgressBar(null);
progressBar = null;
log.withTimestamp(chalk.red('Failed building JavaScript bundle'));
}
});
}
newLogChunks.map(handleLogChunk);
},
});
// Subscribe to device updates separately from packager/server updates
ProjectUtils.attachLoggerStream(projectDir, {
stream: {
write: chunk => {
if (chunk.tag === 'device') {
handleLogChunk(chunk);
}
},
},
type: 'raw',
});
installExitHooks(projectDir, isInteractive);
log.withTimestamp('Starting packager...');
Project.startAsync(projectDir, options).then(
() => {},
reason => {
_startProjectAsync = async (projectRoot) => {
if (this.state.projectRoot) {
return false;
}
if (!projectRoot) {
throw new Error("Could not open project: empty root.");
}
let projectSettings = await ProjectSettings.readAsync(projectRoot);
let xdeProjectId = this._currentOpenProjectXDEId;
ProjectUtils.attachLoggerStream(projectRoot, {
stream: {
write: (chunk) => {
if (this._currentOpenProjectXDEId !== xdeProjectId) {
return;
}
if (chunk.tag === 'device') {
this._handleDeviceLogs(chunk);
} else {
this._appendLogChunk(chunk);
}
},
},
type: 'raw',
});