Skip to content

fix: use appDirectoryPath from projectData #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/before-prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module.exports = function ($logger, $projectData, $usbLiveSyncService) {
return;
}

return converter.convert($logger, $projectData.projectDir);
return converter.convert($logger, $projectData.projectDir, $projectData.appDirectoryPath);
}
9 changes: 7 additions & 2 deletions src/lib/before-watchPatterns.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
var path = require('path');

module.exports = function (hookArgs) {
if (hookArgs.liveSyncData && !hookArgs.liveSyncData.bundle) {
return (args, originalMethod) => {
return originalMethod().then(originalPatterns => {
originalPatterns.push("!app/**/*.scss");
return originalMethod(...args).then(originalPatterns => {
const projectData = hookArgs.projectData;
const appRelativePath = path.relative(projectData.projectDir, projectData.appDirectoryPath);
const pattern = `!${appRelativePath}/**/*.scss`;
originalPatterns.push(pattern);

return originalPatterns;
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ var fs = require('fs');
var path = require('path');
var currentSassProcess = null;

function convert(logger, projectDir, options) {
function convert(logger, projectDir, appDir, options) {
return new Promise(function (resolve, reject) {
options = options || {};
var sassPath = require.resolve('node-sass/bin/node-sass');
var appDir = path.join(projectDir, "app");
var importerPath = path.join(__dirname, "importer.js");

if (fs.existsSync(sassPath)) {
Expand All @@ -36,6 +35,7 @@ function convert(logger, projectDir, options) {
logger.trace(process.execPath, nodeArgs.join(' '));
var env = Object.create( process.env );
env.PROJECT_DIR = projectDir;
env.APP_DIR = appDir;
currentSassProcess = spawn(process.execPath, nodeArgs, { env: env });

var isResolved = false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(url, prev, done) {
url = path.resolve(process.env.PROJECT_DIR, "node_modules", url.substr(1));
} else if (url[0] === '~' && url[1] === '/') {
// Resolve "~/" paths to the app root
url = path.resolve(process.env.PROJECT_DIR, "app/"+ url.substr(2));
url = path.resolve(process.env.APP_DIR, url.substr(2));
}

return { file: url };
Expand Down
2 changes: 1 addition & 1 deletion src/lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ module.exports = function (logger, projectData, usbLiveSyncService, hookArgs) {
}
}

return converter.convert(logger, projectData.projectDir, { watch: true });
return converter.convert(logger, projectData.projectDir, projectData.appDirectoryPath, { watch: true });
}