[gnome-builder] npm: ensure we have a package.json to work with
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] npm: ensure we have a package.json to work with
- Date: Fri, 19 Apr 2019 18:28:28 +0000 (UTC)
commit cb6de2d5931beff2eacf4e6c6afd349bdf005adc
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 19 11:24:01 2019 -0700
npm: ensure we have a package.json to work with
If the user opened the directory as the project, project_file might not
be a package.json, but instead the directory.
This adds a helper to ensure that 'package.json' is used when resolving
what directory is needed in those cases.
Fixes #888
src/plugins/npm/npm_plugin.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/npm/npm_plugin.py b/src/plugins/npm/npm_plugin.py
index 9f82875f9..f920d7ca0 100644
--- a/src/plugins/npm/npm_plugin.py
+++ b/src/plugins/npm/npm_plugin.py
@@ -53,6 +53,11 @@ class NPMBuildSystem(Ide.Object, Ide.BuildSystem):
def do_get_priority(self):
return 100
+ def get_package_json(self):
+ if self.props.project_file.get_basename() != 'package.json':
+ return self.props.project_file.get_child('package.json')
+ else:
+ return self.props.project_file
class NPMPipelineAddin(Ide.Object, Ide.PipelineAddin):
"""
@@ -68,7 +73,7 @@ class NPMPipelineAddin(Ide.Object, Ide.PipelineAddin):
if type(build_system) != NPMBuildSystem:
return
- package_json = build_system.props.project_file
+ package_json = build_system.get_package_json()
config = pipeline.get_config()
builddir = pipeline.get_builddir()
runtime = config.get_runtime()
@@ -193,7 +198,7 @@ class NPMBuildTargetProvider(Ide.Object, Ide.BuildTargetProvider):
code=Gio.IOErrorEnum.NOT_SUPPORTED))
return
- project_file = build_system.project_file
+ project_file = build_system.get_package_json()
project_file.load_contents_async(cancellable, self._on_package_json_loaded, task)
def do_get_targets_finish(self, result):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]