refactor: adjust code to updated dependencies

This commit is contained in:
Karl-Philipp Wulfert
2019-05-27 18:01:58 +02:00
parent 3fda81d279
commit 13b4d3d498
7 changed files with 40 additions and 40 deletions

View File

@@ -12,11 +12,12 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import * as del from 'del';
import {existsSync} from 'fs';
import {basename, dirname, join} from 'path';
import {cwd} from 'process';
import {globPromisified, logger, readFilePromisified, unlinkPromisified, writeFilePromisified} from './common';
import {globPromisified, readFilePromisified, unlinkPromisified, writeFilePromisified} from './common';
const PACK_IDENTIFIER = '/* PACKED BY @openstapps/pack */';
@@ -60,7 +61,7 @@ async function packCliJs(): Promise<void> {
return;
}
logger.info('Adjusting JavaScript CLI...');
Logger.info('Adjusting JavaScript CLI...');
const buffer = await readFilePromisified(path);
const content = buffer.toString();
@@ -137,7 +138,7 @@ async function getAllTypeDefinitions(): Promise<string[]> {
* Pack a list of type definitions into one file
*/
async function packTypeDefinitions(): Promise<void> {
logger.info('Packing TypeScript definition files...');
Logger.info('Packing TypeScript definition files...');
const path = join(cwd(), 'lib', 'index.d.ts');
@@ -251,7 +252,7 @@ async function getAllJavaScriptModules(): Promise<JavaScriptModule[]> {
async function packJavaScriptFiles(): Promise<void> {
const path = join(cwd(), 'lib', 'index.js');
logger.info('Packing JavaScript files...');
Logger.info('Packing JavaScript files...');
await deleteFileIfExistingAndPacked(path);
@@ -293,7 +294,7 @@ async function packJavaScriptFiles(): Promise<void> {
return whiteSpace + 'const ' + importedName + ' = require(\'../src/' + modulePath + '\');';
}
logger.warn('Import ' + importedName + ' could not be found in module.directory ' + modulePath);
Logger.warn('Import ' + importedName + ' could not be found in module.directory ' + modulePath);
}
return line;
@@ -350,7 +351,7 @@ async function deleteFileIfExistingAndPacked(path: string): Promise<void> {
// check if packed by this script
if (content.indexOf(PACK_IDENTIFIER) === 0) {
logger.log('Found `' + path + '` which is packed by this script. Deleting it...');
Logger.log('Found `' + path + '` which is packed by this script. Deleting it...');
return await unlinkPromisified(path);
}
} catch (err) {
@@ -427,7 +428,7 @@ function topologicalSort(modules: JavaScriptModule[]): JavaScriptModule[] {
* Pack
*/
export async function pack() {
logger.log(`Packing project in ${process.cwd()}...`);
Logger.log(`Packing project in ${process.cwd()}...`);
// run all tasks in parallel
const promises: Array<Promise<void>> = [
@@ -439,7 +440,7 @@ export async function pack() {
await Promise.all(promises);
// clean up afterwards
logger.info('Deleting extraneous files...');
Logger.info('Deleting extraneous files...');
await del([
// delete all transpiled files