scss-bundle
Advanced tools
Comparing version 0.0.0-canary.9f111cb to 0.0.0-canary.a470d23
@@ -18,3 +18,3 @@ "use strict"; | ||
.parse(argv); | ||
var config = parsedArguments.config, project = parsedArguments.project, entryFile = parsedArguments.entryFile, ignoreImports = parsedArguments.ignoreImports, includePaths = parsedArguments.includePaths, outFile = parsedArguments.outFile, rootDir = parsedArguments.rootDir, watch = parsedArguments.watch, logLevel = parsedArguments.logLevel; | ||
var config = parsedArguments.config, project = parsedArguments.project, entryFile = parsedArguments.entryFile, ignoreImports = parsedArguments.ignoreImports, includePaths = parsedArguments.includePaths, outFile = parsedArguments.outFile, rootDir = parsedArguments.rootDir, watch = parsedArguments.watch, logLevel = parsedArguments.logLevel, dedupeGlobs = parsedArguments.dedupeGlobs; | ||
return { | ||
@@ -29,5 +29,6 @@ config: config, | ||
watch: watch, | ||
logLevel: logLevel | ||
logLevel: logLevel, | ||
dedupeGlobs: dedupeGlobs | ||
}; | ||
} | ||
exports.resolveArguments = resolveArguments; |
@@ -47,3 +47,3 @@ #!/usr/bin/env node | ||
fileRegistry = {}; | ||
bundler = new bundler_1.Bundler(fileRegistry, config.rootDir); | ||
bundler = new bundler_1.Bundler(fileRegistry, project); | ||
return [4 /*yield*/, bundler.bundle(config.entryFile, config.dedupeGlobs, config.includePaths, config.ignoreImports)]; | ||
@@ -56,4 +56,4 @@ case 1: | ||
bundleResultForEach(bundleResult, function (result) { | ||
if (!result.found && result.tilde && config.rootDir == null) { | ||
logging_1.Log.warn("Found tilde import, but rootDir was not specified."); | ||
if (!result.found && result.tilde && project == null) { | ||
logging_1.Log.warn("Found tilde import, but \"project\" was not specified."); | ||
throw new import_file_not_found_error_1.ImportFileNotFoundError(result.filePath); | ||
@@ -83,11 +83,11 @@ } | ||
function main(argv) { | ||
var _a; | ||
var _a, _b; | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var packageJson, cliOptions, configLocation, stats, projectLocation, stats, config, jsonConfig, error_1, configLocationDir, resolvedLogLevel, logLevelKey, onFileChange, watchFolder, _b, fileRegistry, bundleResult, error_2; | ||
var packageJson, cliOptions, configLocation, stats, projectLocation, stats, config, jsonConfig, error_1, configLocationDir, resolvedLogLevel, logLevelKey, onFileChange, watchFolder, _c, fileRegistry, bundleResult, error_2; | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_c) { | ||
switch (_c.label) { | ||
return tslib_1.__generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: return [4 /*yield*/, fs_extra_1.default.readJson(PACKAGE_JSON_PATH)]; | ||
case 1: | ||
packageJson = _c.sent(); | ||
packageJson = _d.sent(); | ||
cliOptions = arguments_1.resolveArguments(commander_1.default.version(packageJson.version, "-v, --version"), argv); | ||
@@ -97,3 +97,3 @@ if (!(cliOptions.config != null)) return [3 /*break*/, 3]; | ||
case 2: | ||
stats = _c.sent(); | ||
stats = _d.sent(); | ||
if (stats.isDirectory()) { | ||
@@ -105,3 +105,3 @@ configLocation = path_1.default.resolve(cliOptions.config, constants_1.CONFIG_FILE_NAME); | ||
} | ||
_c.label = 3; | ||
_d.label = 3; | ||
case 3: | ||
@@ -111,3 +111,3 @@ if (!(cliOptions.project != null)) return [3 /*break*/, 5]; | ||
case 4: | ||
stats = _c.sent(); | ||
stats = _d.sent(); | ||
if (stats.isDirectory()) { | ||
@@ -117,19 +117,19 @@ projectLocation = cliOptions.project; | ||
else { | ||
logging_1.Log.warn("[DEPRECATED]: Flag \"project\" usage as pointing to the config file directly is deprecated."); | ||
logging_1.Log.warn("[DEPRECATED]: Flag \"project\" pointing to the config file directly is deprecated. Provide a path to the directory where the project is."); | ||
configLocation = cliOptions.project; | ||
projectLocation = path_1.default.dirname(cliOptions.project); | ||
} | ||
_c.label = 5; | ||
_d.label = 5; | ||
case 5: | ||
if (!(configLocation != null)) return [3 /*break*/, 10]; | ||
_c.label = 6; | ||
_d.label = 6; | ||
case 6: | ||
_c.trys.push([6, 8, , 9]); | ||
_d.trys.push([6, 8, , 9]); | ||
return [4 /*yield*/, config_1.resolveConfig(configLocation)]; | ||
case 7: | ||
jsonConfig = _c.sent(); | ||
jsonConfig = _d.sent(); | ||
config = helpers_1.mergeObjects(jsonConfig.bundlerOptions, cliOptions); | ||
return [3 /*break*/, 9]; | ||
case 8: | ||
error_1 = _c.sent(); | ||
error_1 = _d.sent(); | ||
logging_1.Log.error(error_1); | ||
@@ -141,3 +141,3 @@ process.exit(1); | ||
config = cliOptions; | ||
_c.label = 11; | ||
_d.label = 11; | ||
case 11: | ||
@@ -149,6 +149,2 @@ // Resolve project location from config file. | ||
} | ||
if (projectLocation == null) { | ||
logging_1.Log.error("Could not resolve \"project\" directory."); | ||
process.exit(1); | ||
} | ||
if (config.logLevel != null) { | ||
@@ -168,8 +164,4 @@ logLevelKey = helpers_1.resolveLogLevelKey(config.logLevel); | ||
logging_1.Log.info("File changes detected."); | ||
// This is already checked as fail fast. | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return [4 /*yield*/, build(projectLocation, config)]; | ||
case 1: | ||
// This is already checked as fail fast. | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
_a.sent(); | ||
@@ -181,3 +173,6 @@ logging_1.Log.info("Waiting for changes..."); | ||
}); }); | ||
watchFolder = config.rootDir != null ? config.rootDir : projectLocation; | ||
if (!config.rootDir) { | ||
logging_1.Log.warn("rootDir property is missing in config, using current working directory: " + process.cwd()); | ||
} | ||
watchFolder = (_b = config.rootDir, (_b !== null && _b !== void 0 ? _b : process.cwd())); | ||
logging_1.Log.info("Waiting for changes..."); | ||
@@ -187,6 +182,6 @@ chokidar_1.default.watch(watchFolder).on("change", onFileChange); | ||
case 12: | ||
_c.trys.push([12, 14, , 15]); | ||
_d.trys.push([12, 14, , 15]); | ||
return [4 /*yield*/, build(projectLocation, config)]; | ||
case 13: | ||
_b = _c.sent(), fileRegistry = _b.fileRegistry, bundleResult = _b.bundleResult; | ||
_c = _d.sent(), fileRegistry = _c.fileRegistry, bundleResult = _c.bundleResult; | ||
logging_1.Log.info("Imports tree:"); | ||
@@ -197,3 +192,3 @@ logging_1.Log.info(archy_1.renderArchy(bundleResult, projectLocation)); | ||
case 14: | ||
error_2 = _c.sent(); | ||
error_2 = _d.sent(); | ||
logging_1.Log.error(error_2.message); | ||
@@ -200,0 +195,0 @@ process.exit(1); |
@@ -1,1 +0,1 @@ | ||
export declare function renderScss(projectPath: string, includePaths: string[] | undefined, content: string): Promise<{}>; | ||
export declare function renderScss(projectPath: string | undefined, includePaths: string[] | undefined, content: string): Promise<{}>; |
@@ -26,3 +26,3 @@ "use strict"; | ||
data: content, | ||
importer: sassImporter(projectPath), | ||
importer: projectPath != null ? sassImporter(projectPath) : undefined, | ||
includePaths: includePaths | ||
@@ -29,0 +29,0 @@ }, function (error, result) { |
{ | ||
"name": "scss-bundle", | ||
"version": "0.0.0-canary.9f111cb", | ||
"version": "0.0.0-canary.a470d23", | ||
"description": "Bundling SCSS files to one bundled file.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57263
989